4213 | 2023-03-16 17:33:42 | Kicsen | Karácsonyi égők | cpp17 | Wrong answer 0/100 | 1.557s | 7000 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,c,i=0,kicsi,nagy;
cin>>n>>c;
int y=0,t=n;
vector<int> a(n),s(c);
for(i=0;i<n;i++)
cin>>a.at(i);
for(i=0;i<c;i++)
s.at(i)=-1;
for(i=0;i<n;i++)
{
if(s.at(a.at(i))==-1)
{
y++;
s.at(a.at(i))=i;
}
else
{
s.at(a.at(i))=i;
if(y==c)
{
if(kicsi!=*min_element(s.begin(),s.end()))
{
kicsi=*min_element(s.begin(),s.end());
nagy=*max_element(s.begin(),s.end());
if (nagy-kicsi+1<t)
t=nagy-kicsi+1;
}
}
}
}
cout<<t;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1848 KiB | ||||
2 | Accepted | 3ms | 2092 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 39ms | 3688 KiB | ||||
4 | Wrong answer | 37ms | 3892 KiB | ||||
5 | Wrong answer | 37ms | 4060 KiB | ||||
6 | Wrong answer | 3ms | 2924 KiB | ||||
7 | Wrong answer | 3ms | 2896 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Accepted | 2ms | 2888 KiB | ||||
9 | Wrong answer | 3ms | 2976 KiB | ||||
10 | Wrong answer | 3ms | 3100 KiB | ||||
11 | Wrong answer | 3ms | 3352 KiB | ||||
12 | Wrong answer | 3ms | 3288 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Wrong answer | 3ms | 3408 KiB | ||||
14 | Wrong answer | 3ms | 3544 KiB | ||||
15 | Wrong answer | 3ms | 3532 KiB | ||||
16 | Wrong answer | 3ms | 3532 KiB | ||||
17 | Wrong answer | 3ms | 3748 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Accepted | 4ms | 3760 KiB | ||||
19 | Wrong answer | 4ms | 3784 KiB | ||||
20 | Wrong answer | 4ms | 3932 KiB | ||||
21 | Wrong answer | 4ms | 4032 KiB | ||||
22 | Wrong answer | 3ms | 4124 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Accepted | 71ms | 7000 KiB | ||||
24 | Wrong answer | 104ms | 5420 KiB | ||||
25 | Wrong answer | 57ms | 5560 KiB | ||||
26 | Time limit exceeded | 1.557s | 5944 KiB | ||||
27 | Wrong answer | 186ms | 6388 KiB | ||||
28 | Wrong answer | 90ms | 5468 KiB | ||||
29 | Wrong answer | 61ms | 5744 KiB | ||||
30 | Wrong answer | 37ms | 5852 KiB |