4212 | 2023-03-16 17:32:48 | Gabor | Karácsonyi égők | cpp11 | Wrong answer 0/100 | 71ms | 7152 KiB |
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
int n,c,i;
cin>>n>>c;
vector<int> egok(n);
vector<int> szinek(c,-1);
for(i=0;i<n;i++)
cin>>egok.at(i);
int hany=0;
bool tele=false;
int kicsi,tavolsag,nagy,kistav;
for(i=0;i<n;i++)
{
if(szinek.at(egok.at(i))==-1)
{
hany++;
szinek.at(egok.at(i))=i;
if(hany==c)
{
kicsi=*min_element(szinek.begin(),szinek.end());
nagy=*max_element(szinek.begin(),szinek.end());
tele=true;
tavolsag=nagy-kicsi+1;
kistav=tavolsag;
}
}
else if(!tele)
szinek.at(egok.at(i))=i;
else if(tele&&szinek.at(egok.at(i))==kicsi)
{
szinek.at(egok.at(i))=i;
kicsi=*min_element(szinek.begin(),szinek.end());
nagy=*max_element(szinek.begin(),szinek.end());
tavolsag=nagy-kicsi+1;
if(tavolsag<kistav)
kistav=tavolsag;
}
else if(tele)
{
szinek.at(egok.at(i))=i;
}
}
cout<<endl<<tavolsag;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1684 KiB | ||||
2 | Wrong answer | 3ms | 1844 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 37ms | 3288 KiB | ||||
4 | Wrong answer | 37ms | 3412 KiB | ||||
5 | Wrong answer | 37ms | 3900 KiB | ||||
6 | Wrong answer | 3ms | 2652 KiB | ||||
7 | Wrong answer | 3ms | 2896 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 3ms | 2760 KiB | ||||
9 | Wrong answer | 3ms | 2916 KiB | ||||
10 | Wrong answer | 3ms | 3164 KiB | ||||
11 | Wrong answer | 3ms | 3232 KiB | ||||
12 | Wrong answer | 3ms | 3192 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Wrong answer | 3ms | 3200 KiB | ||||
14 | Wrong answer | 3ms | 3324 KiB | ||||
15 | Wrong answer | 3ms | 3572 KiB | ||||
16 | Wrong answer | 3ms | 3676 KiB | ||||
17 | Wrong answer | 3ms | 3924 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Wrong answer | 4ms | 3972 KiB | ||||
19 | Wrong answer | 4ms | 3956 KiB | ||||
20 | Wrong answer | 4ms | 4176 KiB | ||||
21 | Wrong answer | 3ms | 4160 KiB | ||||
22 | Wrong answer | 4ms | 4160 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Wrong answer | 71ms | 7152 KiB | ||||
24 | Wrong answer | 48ms | 5556 KiB | ||||
25 | Wrong answer | 54ms | 5588 KiB | ||||
26 | Wrong answer | 67ms | 5984 KiB | ||||
27 | Wrong answer | 68ms | 6500 KiB | ||||
28 | Wrong answer | 54ms | 5668 KiB | ||||
29 | Wrong answer | 48ms | 5652 KiB | ||||
30 | Wrong answer | 37ms | 5712 KiB |