116702024-11-04 18:20:59bzyKarácsonyi égőkcpp17Time limit exceeded 70/1001.6s1968 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll  long long

int main()
{
    int n, c; cin >> n >> c;
    vector <int> L(n);
    for(int i = 0; i < n; i++) cin >> L[i];
    vector <int> A(c, 0);
    int ans = n;
    int l = 0, r = 0;
    while(r < n){
        A[L[r]]++;
        if(!count(A.begin(), A.end(), 0)){
            while(A[L[l]]-1 > 0){

                A[L[l]]--;
                l++;
            }
            ans = min(ans, r - l + 1);
        }
        r++;
    }
    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
2Accepted1ms320 KiB
subtask215/15
3Accepted37ms1080 KiB
4Accepted37ms1120 KiB
5Accepted37ms1056 KiB
6Accepted1ms320 KiB
7Accepted1ms320 KiB
subtask310/10
8Accepted1ms320 KiB
9Accepted1ms320 KiB
10Accepted1ms320 KiB
11Accepted1ms508 KiB
12Accepted1ms524 KiB
subtask420/20
13Accepted1ms340 KiB
14Accepted1ms320 KiB
15Accepted1ms320 KiB
16Accepted1ms508 KiB
17Accepted1ms372 KiB
subtask525/25
18Accepted17ms432 KiB
19Accepted4ms320 KiB
20Accepted4ms320 KiB
21Accepted2ms320 KiB
22Accepted2ms320 KiB
subtask60/30
23Time limit exceeded1.6s1968 KiB
24Accepted115ms1080 KiB
25Accepted305ms1080 KiB
26Time limit exceeded1.6s1200 KiB
27Time limit exceeded1.58s1340 KiB
28Accepted303ms1080 KiB
29Accepted114ms1080 KiB
30Accepted37ms1080 KiB