118042024-11-11 17:53:50MCDaveKarácsonyi égőkcpp17Wrong answer 80/10071ms1848 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, c, i, min, left = 0, x = 0;
    cin >> n >> c;
    vector<int> all(n), lights(c, 0);
    min = n - 1;

    for (i = 0; i < n; i++)
    {
        cin >> all[i];
        if (x < c and lights[all[i]] == 0) x++;
        lights[all[i]]++;
        while (x == c and lights[all[left]] > 1)
        {
            lights[all[left]]--, left++;
            if (i - left < min) min = i - left;
        }
    }

    cout << min + 1;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
2Accepted1ms320 KiB
subtask215/15
3Accepted37ms1080 KiB
4Accepted37ms1196 KiB
5Accepted37ms1080 KiB
6Accepted1ms320 KiB
7Accepted1ms320 KiB
subtask310/10
8Accepted2ms320 KiB
9Accepted1ms544 KiB
10Accepted1ms320 KiB
11Accepted2ms320 KiB
12Accepted1ms320 KiB
subtask40/20
13Accepted1ms320 KiB
14Accepted1ms320 KiB
15Accepted1ms320 KiB
16Wrong answer1ms320 KiB
17Accepted1ms320 KiB
subtask525/25
18Accepted3ms320 KiB
19Accepted2ms320 KiB
20Accepted2ms512 KiB
21Accepted2ms320 KiB
22Accepted2ms320 KiB
subtask630/30
23Accepted71ms1848 KiB
24Accepted48ms1080 KiB
25Accepted54ms1204 KiB
26Accepted65ms1396 KiB
27Accepted68ms1336 KiB
28Accepted54ms1208 KiB
29Accepted48ms1080 KiB
30Accepted35ms1080 KiB