42132023-03-16 17:33:42KicsenKarácsonyi égőkcpp17Wrong answer 0/1001.557s7000 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c,i=0,kicsi,nagy;
    cin>>n>>c;
    int y=0,t=n;
    vector<int> a(n),s(c);
    for(i=0;i<n;i++)
        cin>>a.at(i);
    for(i=0;i<c;i++)
        s.at(i)=-1;
    for(i=0;i<n;i++)
    {
        if(s.at(a.at(i))==-1)
        {
            y++;
            s.at(a.at(i))=i;
        }
        else
        {
            s.at(a.at(i))=i;
            if(y==c)
            {
                if(kicsi!=*min_element(s.begin(),s.end()))
                {
                kicsi=*min_element(s.begin(),s.end());
                nagy=*max_element(s.begin(),s.end());
                if (nagy-kicsi+1<t)
                    t=nagy-kicsi+1;
                }
            }
        }
    }
    cout<<t;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1848 KiB
2Accepted3ms2092 KiB
subtask20/15
3Wrong answer39ms3688 KiB
4Wrong answer37ms3892 KiB
5Wrong answer37ms4060 KiB
6Wrong answer3ms2924 KiB
7Wrong answer3ms2896 KiB
subtask30/10
8Accepted2ms2888 KiB
9Wrong answer3ms2976 KiB
10Wrong answer3ms3100 KiB
11Wrong answer3ms3352 KiB
12Wrong answer3ms3288 KiB
subtask40/20
13Wrong answer3ms3408 KiB
14Wrong answer3ms3544 KiB
15Wrong answer3ms3532 KiB
16Wrong answer3ms3532 KiB
17Wrong answer3ms3748 KiB
subtask50/25
18Accepted4ms3760 KiB
19Wrong answer4ms3784 KiB
20Wrong answer4ms3932 KiB
21Wrong answer4ms4032 KiB
22Wrong answer3ms4124 KiB
subtask60/30
23Accepted71ms7000 KiB
24Wrong answer104ms5420 KiB
25Wrong answer57ms5560 KiB
26Time limit exceeded1.557s5944 KiB
27Wrong answer186ms6388 KiB
28Wrong answer90ms5468 KiB
29Wrong answer61ms5744 KiB
30Wrong answer37ms5852 KiB