4210 | 2023-03-16 17:15:47 | balaaaazs | Karácsonyi égők | cpp14 | Time limit exceeded 70/100 | 1.547s | 7016 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
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;
int sz=0;
int sz1=0;
for(int i=0;i<n;i++)
{
cin>>egok.at(i);
if(indt.at(egok.at(i))==-1)
sz++;
indt.at(egok.at(i))=i;
if(sz>=c)
{
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 | 1680 KiB | ||||
2 | Accepted | 3ms | 1852 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 39ms | 4892 KiB | ||||
4 | Accepted | 39ms | 4468 KiB | ||||
5 | Accepted | 37ms | 4648 KiB | ||||
6 | Accepted | 3ms | 2696 KiB | ||||
7 | Accepted | 3ms | 2784 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 3ms | 2908 KiB | ||||
9 | Accepted | 3ms | 3148 KiB | ||||
10 | Accepted | 3ms | 3364 KiB | ||||
11 | Accepted | 3ms | 3468 KiB | ||||
12 | Accepted | 3ms | 3412 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 3ms | 3560 KiB | ||||
14 | Accepted | 3ms | 3612 KiB | ||||
15 | Accepted | 3ms | 3736 KiB | ||||
16 | Accepted | 3ms | 3752 KiB | ||||
17 | Accepted | 3ms | 3820 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 4ms | 3856 KiB | ||||
19 | Accepted | 4ms | 4000 KiB | ||||
20 | Accepted | 7ms | 4336 KiB | ||||
21 | Accepted | 4ms | 4156 KiB | ||||
22 | Accepted | 4ms | 4280 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Accepted | 74ms | 7016 KiB | ||||
24 | Accepted | 158ms | 6912 KiB | ||||
25 | Accepted | 59ms | 5744 KiB | ||||
26 | Time limit exceeded | 1.547s | 4908 KiB | ||||
27 | Accepted | 298ms | 6720 KiB | ||||
28 | Accepted | 126ms | 6316 KiB | ||||
29 | Accepted | 75ms | 6428 KiB | ||||
30 | Accepted | 37ms | 6416 KiB |