10629 | 2024-04-07 00:20:52 | 111 | Karácsonyi égők | cpp17 | Wrong answer 0/100 | 30ms | 18628 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
int ans=N;
vector<int>v(M,-1);
deque<pair<int,int>>q;
for(int i=0;i<N;i++){
int x;
cin>>x;
v[x]=i;
q.emplace_back(x,i);
while(v[q.front().first]!=q.front().second){
q.pop_front();
}
if(q.size()>=M){
ans=min(ans,q.back().second-q.front().second+2);
}
}
cout<<ans<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2084 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 20ms | 6100 KiB | ||||
4 | Wrong answer | 20ms | 6700 KiB | ||||
5 | Wrong answer | 20ms | 7012 KiB | ||||
6 | Wrong answer | 3ms | 4236 KiB | ||||
7 | Wrong answer | 3ms | 4240 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Accepted | 2ms | 4104 KiB | ||||
9 | Wrong answer | 3ms | 4176 KiB | ||||
10 | Wrong answer | 2ms | 4240 KiB | ||||
11 | Wrong answer | 3ms | 4248 KiB | ||||
12 | Wrong answer | 2ms | 4252 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Wrong answer | 3ms | 4388 KiB | ||||
14 | Wrong answer | 3ms | 4620 KiB | ||||
15 | Wrong answer | 3ms | 4716 KiB | ||||
16 | Wrong answer | 3ms | 4936 KiB | ||||
17 | Wrong answer | 3ms | 5148 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Accepted | 3ms | 5380 KiB | ||||
19 | Wrong answer | 3ms | 5548 KiB | ||||
20 | Wrong answer | 3ms | 5608 KiB | ||||
21 | Wrong answer | 3ms | 5472 KiB | ||||
22 | Wrong answer | 3ms | 5504 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Accepted | 30ms | 16408 KiB | ||||
24 | Wrong answer | 24ms | 13520 KiB | ||||
25 | Wrong answer | 26ms | 14404 KiB | ||||
26 | Wrong answer | 28ms | 16048 KiB | ||||
27 | Wrong answer | 28ms | 18628 KiB | ||||
28 | Wrong answer | 26ms | 17716 KiB | ||||
29 | Wrong answer | 23ms | 14264 KiB | ||||
30 | Wrong answer | 19ms | 17824 KiB |