4226 | 2023-03-16 18:09:18 | balaaaazs | Karácsonyi égők | cpp14 | Time limit exceeded 70/100 | 1.569s | 6052 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n,c;
cin>>n>>c;
vector<int> egok(n);
vector<int> indt(c,-1);
int tav,kistav,kicsi,nagy,kicsi2;
int sz=0;
bool tele=false;
for(int i=0;i<n;i++)
{
cin>>egok.at(i);
indt.at(egok.at(i))=i;
kicsi=*min_element(indt.begin(),indt.end());
if(kicsi!=-1)
tele=true;
if(tele)
{
nagy=*max_element(indt.begin(),indt.end());
if(sz==0){
tav=nagy-kicsi+1;
kistav=tav;
sz++;
}
else
{
tav=nagy-kicsi+1;
if(kistav<tav)
tav=kistav;
}
}
}
cout<<tav;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Accepted | 3ms | 2004 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 37ms | 3600 KiB | ||||
4 | Accepted | 37ms | 3656 KiB | ||||
5 | Accepted | 37ms | 3880 KiB | ||||
6 | Accepted | 3ms | 2888 KiB | ||||
7 | Accepted | 3ms | 2916 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 3ms | 3032 KiB | ||||
9 | Accepted | 3ms | 3244 KiB | ||||
10 | Accepted | 3ms | 3324 KiB | ||||
11 | Accepted | 3ms | 3456 KiB | ||||
12 | Accepted | 3ms | 3540 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 3ms | 3540 KiB | ||||
14 | Accepted | 3ms | 3544 KiB | ||||
15 | Accepted | 3ms | 3544 KiB | ||||
16 | Accepted | 3ms | 3608 KiB | ||||
17 | Accepted | 3ms | 3612 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 28ms | 4020 KiB | ||||
19 | Accepted | 7ms | 3836 KiB | ||||
20 | Accepted | 8ms | 3940 KiB | ||||
21 | Accepted | 4ms | 4164 KiB | ||||
22 | Accepted | 3ms | 4276 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Time limit exceeded | 1.55s | 5408 KiB | ||||
24 | Accepted | 201ms | 6052 KiB | ||||
25 | Accepted | 442ms | 5940 KiB | ||||
26 | Time limit exceeded | 1.567s | 4748 KiB | ||||
27 | Time limit exceeded | 1.569s | 5024 KiB | ||||
28 | Accepted | 474ms | 5832 KiB | ||||
29 | Accepted | 158ms | 5840 KiB | ||||
30 | Accepted | 37ms | 6028 KiB |