42172023-03-16 17:37:18KicsenKarácsonyi égőkcpp17Wrong answer 0/1001.564s6900 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 if (y==c)
        {
            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;
                }
            }
        }
        else
            s.at(a.at(i))=i;
    }
    cout<<t;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1688 KiB
2Accepted3ms1948 KiB
subtask20/15
3Wrong answer37ms3304 KiB
4Wrong answer37ms3496 KiB
5Wrong answer37ms3688 KiB
6Wrong answer3ms2468 KiB
7Wrong answer3ms2552 KiB
subtask30/10
8Accepted3ms2796 KiB
9Wrong answer3ms2916 KiB
10Wrong answer3ms3136 KiB
11Wrong answer3ms3352 KiB
12Wrong answer3ms3700 KiB
subtask40/20
13Wrong answer3ms3612 KiB
14Wrong answer3ms3612 KiB
15Wrong answer3ms3736 KiB
16Wrong answer3ms3792 KiB
17Wrong answer3ms3916 KiB
subtask50/25
18Accepted4ms4068 KiB
19Wrong answer6ms3940 KiB
20Wrong answer8ms4044 KiB
21Wrong answer3ms4120 KiB
22Wrong answer3ms4012 KiB
subtask60/30
23Accepted70ms6900 KiB
24Wrong answer228ms5344 KiB
25Wrong answer64ms5244 KiB
26Time limit exceeded1.564s4380 KiB
27Wrong answer474ms6444 KiB
28Wrong answer180ms5536 KiB
29Wrong answer90ms5532 KiB
30Wrong answer37ms5532 KiB