4209 | 2023-03-16 17:00:06 | balaaaazs | Karácsonyi égők | cpp14 | Time limit exceeded 70/100 | 1.567s | 7368 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void kiir(const vector<int>& v)
{
for(auto x:v)
cout<<x<<" ";
cout<<endl;
}
bool voltmind(const vector<int>& v)
{
for(int i=0;i<v.size();i++)
if(v.at(i)==-1)
return false;
return true;
}
int main()
{
int n,c;
cin>>n>>c;
vector<int> egok(n);
vector<int> indt(c,-1);
vector<int> valaszok;
for(int i=0;i<n;i++){
cin>>egok.at(i);
indt.at(egok.at(i))=i;
if(voltmind(indt))
{
int kicsi=*min_element(indt.begin(),indt.end());
int nagy=*max_element(indt.begin(),indt.end());
valaszok.push_back(nagy-kicsi+1);
}
}
cout<<*min_element(valaszok.begin(),valaszok.end());
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Accepted | 3ms | 2052 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 39ms | 5020 KiB | ||||
4 | Accepted | 39ms | 4616 KiB | ||||
5 | Accepted | 37ms | 4928 KiB | ||||
6 | Accepted | 3ms | 2952 KiB | ||||
7 | Accepted | 3ms | 3044 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 3ms | 3164 KiB | ||||
9 | Accepted | 3ms | 3276 KiB | ||||
10 | Accepted | 3ms | 3408 KiB | ||||
11 | Accepted | 2ms | 3488 KiB | ||||
12 | Accepted | 3ms | 3484 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 3ms | 3724 KiB | ||||
14 | Accepted | 3ms | 3940 KiB | ||||
15 | Accepted | 3ms | 4056 KiB | ||||
16 | Accepted | 3ms | 4184 KiB | ||||
17 | Accepted | 3ms | 4272 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 4ms | 4280 KiB | ||||
19 | Accepted | 4ms | 4352 KiB | ||||
20 | Accepted | 8ms | 4456 KiB | ||||
21 | Accepted | 4ms | 4392 KiB | ||||
22 | Accepted | 3ms | 4496 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Accepted | 72ms | 7368 KiB | ||||
24 | Accepted | 222ms | 7132 KiB | ||||
25 | Accepted | 287ms | 5804 KiB | ||||
26 | Time limit exceeded | 1.567s | 4692 KiB | ||||
27 | Accepted | 389ms | 6692 KiB | ||||
28 | Accepted | 321ms | 6348 KiB | ||||
29 | Accepted | 92ms | 6464 KiB | ||||
30 | Accepted | 39ms | 6336 KiB |