6112 | 2023-11-01 16:25:56 | Ghost | Karácsonyi égők | cpp17 | Wrong answer 0/100 | 162ms | 26524 KiB |
#include <iostream>
#include <vector>
#include <set>
#include <limits.h>
using namespace std;
int main()
{
int n, c, i, out = INT_MAX;
cin >> n >> c;
vector<int> lights(n);
for (i = 0; i < n; i++) {
cin >> lights[i];
}
vector<int> colors(c, 0);
set<int> present;
int back = 0;
i = 0;
while (i < n) {
if (present.size() < c) {
present.insert(lights[i]);
colors[lights[i]]++;
}
if (present.size() == c) {
if (out > i - back) {
out = i - back;
}
colors[lights[back]]--;
if (colors[lights[back]] == 0) {
present.erase(lights[back]);
}
back++;
}
i++;
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1804 KiB | ||||
2 | Wrong answer | 3ms | 2060 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 39ms | 3672 KiB | ||||
4 | Wrong answer | 39ms | 3852 KiB | ||||
5 | Wrong answer | 39ms | 4052 KiB | ||||
6 | Wrong answer | 3ms | 2784 KiB | ||||
7 | Wrong answer | 3ms | 2912 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 3ms | 3120 KiB | ||||
9 | Wrong answer | 3ms | 3220 KiB | ||||
10 | Wrong answer | 3ms | 3308 KiB | ||||
11 | Wrong answer | 3ms | 3412 KiB | ||||
12 | Wrong answer | 2ms | 3456 KiB | ||||
subtask4 | 0/20 | ||||||
13 | Wrong answer | 3ms | 3716 KiB | ||||
14 | Wrong answer | 3ms | 4072 KiB | ||||
15 | Wrong answer | 3ms | 4052 KiB | ||||
16 | Wrong answer | 3ms | 4004 KiB | ||||
17 | Wrong answer | 3ms | 4108 KiB | ||||
subtask5 | 0/25 | ||||||
18 | Wrong answer | 4ms | 4760 KiB | ||||
19 | Wrong answer | 4ms | 4520 KiB | ||||
20 | Wrong answer | 4ms | 4716 KiB | ||||
21 | Wrong answer | 4ms | 4784 KiB | ||||
22 | Wrong answer | 4ms | 4824 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Wrong answer | 162ms | 26524 KiB | ||||
24 | Wrong answer | 61ms | 6152 KiB | ||||
25 | Wrong answer | 71ms | 6616 KiB | ||||
26 | Wrong answer | 101ms | 11476 KiB | ||||
27 | Wrong answer | 119ms | 16372 KiB | ||||
28 | Wrong answer | 71ms | 6648 KiB | ||||
29 | Wrong answer | 59ms | 6404 KiB | ||||
30 | Wrong answer | 39ms | 6296 KiB |