27632023-01-22 21:42:04KovácsHunorKarácsonyi égőkcpp11Wrong answer 55/1001.577s5928 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 main() {
    cin >> n >> c;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    for (int i = 0; i < n; i++) {
        memset(used, 0, sizeof(used));
        int cnt = 0;
        for (int j = i; j < n; j++) {
            if (!used[l[j]]) {
                used[l[j]] = true;
                cnt++;
            }
            if (cnt == c) {
                ans = min(ans, j - i + 1);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms2104 KiB
2Accepted2ms2372 KiB
subtask20/15
3Wrong answer19ms3144 KiB
4Wrong answer18ms3404 KiB
5Wrong answer18ms3680 KiB
6Accepted8ms2824 KiB
7Accepted8ms3076 KiB
subtask310/10
8Accepted2ms3016 KiB
9Accepted2ms3032 KiB
10Accepted2ms3304 KiB
11Accepted2ms3520 KiB
12Accepted2ms3444 KiB
subtask420/20
13Accepted4ms3636 KiB
14Accepted4ms3588 KiB
15Accepted4ms3848 KiB
16Accepted4ms4100 KiB
17Accepted4ms4304 KiB
subtask525/25
18Accepted48ms4528 KiB
19Accepted48ms4724 KiB
20Accepted45ms4776 KiB
21Accepted43ms4780 KiB
22Accepted39ms4984 KiB
subtask60/30
23Runtime error35ms5928 KiB
24Wrong answer26ms5792 KiB
25Wrong answer32ms5568 KiB
26Time limit exceeded1.56s4420 KiB
27Time limit exceeded1.577s4292 KiB
28Wrong answer37ms5580 KiB
29Wrong answer28ms5580 KiB
30Wrong answer19ms5840 KiB