182832025-10-17 15:00:16MagyarKendeSZLGKarácsonyi égőkcpp17Wrong answer 0/100162ms14296 KiB
#include <bits/stdc++.h>
using namespace std;
#define int int64_t

int32_t main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int n, c;
    cin >> n >> c;
    vector<int> a(n);
    for (int& x : a) cin >> x;
    map<int, int> m;
    int l = 0, result = 1e9;
    for (int r = 0; r < n; r++) {
        m[a[r]]++;
        while (r < l && m.size() == c) {
            if (m[l] == 1) break;
            m[a[l]]--;
            l++;
        }
        if (m.size() == c) {
            result = min(result, r - l + 1);
        }
    }
    cout << result << "\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer1ms316 KiB
2Wrong answer1ms316 KiB
subtask20/15
3Wrong answer17ms1848 KiB
4Wrong answer17ms1848 KiB
5Wrong answer17ms1844 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms316 KiB
subtask30/10
8Accepted1ms424 KiB
9Wrong answer1ms508 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
12Wrong answer1ms316 KiB
subtask40/20
13Wrong answer1ms500 KiB
14Wrong answer1ms316 KiB
15Wrong answer1ms316 KiB
16Accepted1ms316 KiB
17Wrong answer1ms316 KiB
subtask50/25
18Accepted3ms716 KiB
19Wrong answer2ms316 KiB
20Wrong answer2ms316 KiB
21Wrong answer2ms472 KiB
22Wrong answer1ms316 KiB
subtask60/30
23Accepted162ms14296 KiB
24Wrong answer34ms2004 KiB
25Wrong answer43ms2008 KiB
26Wrong answer78ms5116 KiB
27Wrong answer108ms8240 KiB
28Wrong answer43ms2000 KiB
29Wrong answer34ms1844 KiB
30Wrong answer17ms1868 KiB