11782 | 2024-11-10 17:59:35 | Mittomen | Karácsonyi égők | cpp17 | Accepted 100/100 | 71ms | 1268 KiB |
#include <iostream>
#include <cstdint>
#include <vector>
using namespace std;
int main() {
int n, c;
vector<int> lights;
vector<bool> colors;
int colors_found = 0;
cin >> n >> c;
lights.resize(n);
colors.resize(c);
for (int& li : lights) {
cin >> li;
}
int r = 0;
while (colors_found != c) {
if (!colors[lights[r]]) colors_found++;
colors[lights[r]] = true;
r++;
}
colors_found = 0;
int l = r;
colors.clear();
colors.resize(c);
while (colors_found != c) {
if (!colors[lights[l]]) colors_found++;
colors[lights[l]] = true;
l--;
}
cout << r - l - 1;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 37ms | 1080 KiB | ||||
4 | Accepted | 37ms | 1080 KiB | ||||
5 | Accepted | 37ms | 1080 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Accepted | 1ms | 320 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 1ms | 320 KiB | ||||
9 | Accepted | 1ms | 320 KiB | ||||
10 | Accepted | 1ms | 320 KiB | ||||
11 | Accepted | 1ms | 500 KiB | ||||
12 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 2ms | 508 KiB | ||||
14 | Accepted | 1ms | 544 KiB | ||||
15 | Accepted | 1ms | 508 KiB | ||||
16 | Accepted | 1ms | 320 KiB | ||||
17 | Accepted | 1ms | 320 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 3ms | 320 KiB | ||||
19 | Accepted | 2ms | 320 KiB | ||||
20 | Accepted | 2ms | 320 KiB | ||||
21 | Accepted | 2ms | 320 KiB | ||||
22 | Accepted | 2ms | 320 KiB | ||||
subtask6 | 30/30 | ||||||
23 | Accepted | 71ms | 1080 KiB | ||||
24 | Accepted | 48ms | 1196 KiB | ||||
25 | Accepted | 54ms | 1128 KiB | ||||
26 | Accepted | 65ms | 1080 KiB | ||||
27 | Accepted | 68ms | 1268 KiB | ||||
28 | Accepted | 54ms | 1196 KiB | ||||
29 | Accepted | 48ms | 1080 KiB | ||||
30 | Accepted | 37ms | 1080 KiB |