11803 | 2024-11-11 17:53:07 | MCDave | Karácsonyi égők | cpp17 | Wrong answer 15/100 | 71ms | 1980 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 35ms | 1080 KiB | ||||
4 | Accepted | 35ms | 1080 KiB | ||||
5 | Accepted | 35ms | 1080 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Accepted | 1ms | 392 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 1ms | 320 KiB | ||||
9 | Accepted | 1ms | 320 KiB | ||||
10 | Accepted | 1ms | 508 KiB | ||||
11 | Accepted | 1ms | 572 KiB | ||||
12 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Accepted | 1ms | 320 KiB | ||||
14 | Accepted | 1ms | 320 KiB | ||||
15 | Accepted | 1ms | 320 KiB | ||||
16 | Wrong answer | 1ms | 552 KiB | ||||
17 | Accepted | 1ms | 500 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Wrong answer | 2ms | 320 KiB | ||||
19 | Accepted | 2ms | 320 KiB | ||||
20 | Accepted | 2ms | 320 KiB | ||||
21 | Accepted | 2ms | 320 KiB | ||||
22 | Accepted | 2ms | 320 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Wrong answer | 71ms | 1980 KiB | ||||
24 | Accepted | 46ms | 1080 KiB | ||||
25 | Accepted | 52ms | 1212 KiB | ||||
26 | Accepted | 64ms | 1396 KiB | ||||
27 | Accepted | 67ms | 1592 KiB | ||||
28 | Accepted | 52ms | 1260 KiB | ||||
29 | Accepted | 46ms | 1192 KiB | ||||
30 | Accepted | 35ms | 1080 KiB |