27642023-01-22 21:43:08KovácsHunorKarácsonyi égőkcpp11Wrong answer 0/10035ms5172 KiB
#include <iostream>
#include <cstring>
using namespace std;

const int MAX_N = 100000;

int n, c;
int l[MAX_N];
bool used[MAX_N];
int ans = MAX_N;
int cnt = 0;
int start = 0;

int main() {
    cin >> n >> c;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    for (int end = 0; end < n; end++) {
        if (!used[l[end]]) {
            used[l[end]] = true;
            cnt++;
        }
        while (cnt == c) {
            ans = min(ans, end - start + 1);
            used[l[start]] = false;
            cnt--;
            start++;
        }
    }
    cout << ans << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1760 KiB
2Wrong answer2ms1920 KiB
subtask20/15
3Wrong answer19ms2764 KiB
4Wrong answer18ms2892 KiB
5Wrong answer18ms3000 KiB
6Wrong answer2ms2356 KiB
7Wrong answer2ms2532 KiB
subtask30/10
8Accepted2ms2776 KiB
9Wrong answer2ms2972 KiB
10Wrong answer2ms3172 KiB
11Wrong answer2ms3380 KiB
12Wrong answer2ms3488 KiB
subtask40/20
13Wrong answer2ms3568 KiB
14Wrong answer2ms3564 KiB
15Wrong answer2ms3428 KiB
16Accepted2ms3560 KiB
17Wrong answer2ms3660 KiB
subtask50/25
18Accepted3ms3676 KiB
19Wrong answer3ms3668 KiB
20Wrong answer3ms3796 KiB
21Wrong answer3ms3872 KiB
22Wrong answer3ms4024 KiB
subtask60/30
23Runtime error35ms5172 KiB
24Wrong answer26ms4916 KiB
25Wrong answer28ms4916 KiB
26Wrong answer34ms4872 KiB
27Wrong answer35ms4976 KiB
28Wrong answer28ms4880 KiB
29Wrong answer26ms4884 KiB
30Wrong answer18ms4828 KiB