4216 | 2023-03-16 17:36:58 | Markopolo | Karácsonyi égők | cpp14 | Wrong answer 0/100 | 96ms | 7216 KiB |
#include<bits/stdc++.h>
using namespace std;
/*
10 4
0 1 3 0 0 1 2 0 2 3
*/
int main()
{
int n,c,i,sz,h=0,kicsi,nagy,tav,kt; // h a szin vektor kitoltott elemeinek szama
cin>>n>>c;
vector<int> szin(c,-1); // ez az indextabla
vector<int> ego(n);
for(i=0;i<n;i++)
cin>>ego.at(i);
bool t=false;
for(i=0;i<n;i++)
{
sz=ego.at(i);
if(szin.at(sz)==-1)
{
h++;
szin.at(sz)=i;
if(h==c) // amiko tele van sz index
{
kicsi=*min_element(szin.begin(),szin.end());
nagy=*max_element(szin.begin(),szin.end());
cout<<kicsi<< " "<<nagy<<endl;
t=true;
tav=nagy-kicsi+1;
kt=t;
}
}
else if(!t)
szin.at(sz)=i;
else if(t && szin.at(sz)==kicsi)
{
szin.at(sz)=i;
kicsi=*min_element(szin.begin(),szin.end());
nagy=*max_element(szin.begin(),szin.end());
cout<<kicsi<< " "<<nagy<<endl;
tav=nagy-kicsi+1;
if(tav<kt)
kt=tav;
}
else if(t)
{
szin.at(sz)=i;
}
}
for(int x : szin)
cout<<x<< " ";
cout<<endl<<tav<<endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1812 KiB | ||||
2 | Wrong answer | 3ms | 2060 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 37ms | 3616 KiB | ||||
4 | Wrong answer | 37ms | 3836 KiB | ||||
5 | Wrong answer | 37ms | 3996 KiB | ||||
6 | Wrong answer | 3ms | 2736 KiB | ||||
7 | Wrong answer | 3ms | 2732 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 3ms | 2976 KiB | ||||
9 | Wrong answer | 3ms | 3060 KiB | ||||
10 | Wrong answer | 3ms | 3056 KiB | ||||
11 | Wrong answer | 3ms | 3184 KiB | ||||
12 | Wrong answer | 3ms | 3180 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Wrong answer | 3ms | 3256 KiB | ||||
14 | Wrong answer | 3ms | 3252 KiB | ||||
15 | Wrong answer | 3ms | 3260 KiB | ||||
16 | Wrong answer | 3ms | 3268 KiB | ||||
17 | Wrong answer | 3ms | 3392 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Wrong answer | 4ms | 3548 KiB | ||||
19 | Wrong answer | 4ms | 3804 KiB | ||||
20 | Wrong answer | 4ms | 3916 KiB | ||||
21 | Wrong answer | 4ms | 3992 KiB | ||||
22 | Wrong answer | 3ms | 4060 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Wrong answer | 96ms | 7216 KiB | ||||
24 | Wrong answer | 50ms | 5564 KiB | ||||
25 | Wrong answer | 54ms | 5712 KiB | ||||
26 | Wrong answer | 75ms | 5976 KiB | ||||
27 | Wrong answer | 82ms | 6496 KiB | ||||
28 | Wrong answer | 54ms | 5532 KiB | ||||
29 | Wrong answer | 50ms | 5660 KiB | ||||
30 | Wrong answer | 37ms | 5672 KiB |