118032024-11-11 17:53:07MCDaveKarácsonyi égőkcpp17Wrong answer 15/10071ms1980 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;

    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
3Accepted35ms1080 KiB
4Accepted35ms1080 KiB
5Accepted35ms1080 KiB
6Accepted1ms320 KiB
7Accepted1ms392 KiB
subtask30/10
8Wrong answer1ms320 KiB
9Accepted1ms320 KiB
10Accepted1ms508 KiB
11Accepted1ms572 KiB
12Accepted1ms320 KiB
subtask40/20
13Accepted1ms320 KiB
14Accepted1ms320 KiB
15Accepted1ms320 KiB
16Wrong answer1ms552 KiB
17Accepted1ms500 KiB
subtask50/25
18Wrong answer2ms320 KiB
19Accepted2ms320 KiB
20Accepted2ms320 KiB
21Accepted2ms320 KiB
22Accepted2ms320 KiB
subtask60/30
23Wrong answer71ms1980 KiB
24Accepted46ms1080 KiB
25Accepted52ms1212 KiB
26Accepted64ms1396 KiB
27Accepted67ms1592 KiB
28Accepted52ms1260 KiB
29Accepted46ms1192 KiB
30Accepted35ms1080 KiB