4217 | 2023-03-16 17:37:18 | Kicsen | Karácsonyi égők | cpp17 | Wrong answer 0/100 | 1.564s | 6900 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 if (y==c)
{
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;
}
}
}
else
s.at(a.at(i))=i;
}
cout<<t;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1688 KiB | ||||
2 | Accepted | 3ms | 1948 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 37ms | 3304 KiB | ||||
4 | Wrong answer | 37ms | 3496 KiB | ||||
5 | Wrong answer | 37ms | 3688 KiB | ||||
6 | Wrong answer | 3ms | 2468 KiB | ||||
7 | Wrong answer | 3ms | 2552 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Accepted | 3ms | 2796 KiB | ||||
9 | Wrong answer | 3ms | 2916 KiB | ||||
10 | Wrong answer | 3ms | 3136 KiB | ||||
11 | Wrong answer | 3ms | 3352 KiB | ||||
12 | Wrong answer | 3ms | 3700 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Wrong answer | 3ms | 3612 KiB | ||||
14 | Wrong answer | 3ms | 3612 KiB | ||||
15 | Wrong answer | 3ms | 3736 KiB | ||||
16 | Wrong answer | 3ms | 3792 KiB | ||||
17 | Wrong answer | 3ms | 3916 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Accepted | 4ms | 4068 KiB | ||||
19 | Wrong answer | 6ms | 3940 KiB | ||||
20 | Wrong answer | 8ms | 4044 KiB | ||||
21 | Wrong answer | 3ms | 4120 KiB | ||||
22 | Wrong answer | 3ms | 4012 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Accepted | 70ms | 6900 KiB | ||||
24 | Wrong answer | 228ms | 5344 KiB | ||||
25 | Wrong answer | 64ms | 5244 KiB | ||||
26 | Time limit exceeded | 1.564s | 4380 KiB | ||||
27 | Wrong answer | 474ms | 6444 KiB | ||||
28 | Wrong answer | 180ms | 5536 KiB | ||||
29 | Wrong answer | 90ms | 5532 KiB | ||||
30 | Wrong answer | 37ms | 5532 KiB |