2760 | 2023-01-21 22:08:50 | renn | Karácsonyi égők | cpp11 | Accepted 100/100 | 26ms | 7040 KiB |
#include <bits/stdc++.h>
using namespace std;
#define InTheNameOfGod cin.tie(0); ios::sync_with_stdio(0);
int main() {
InTheNameOfGod
int N, C;
cin >> N >> C;
vector<int> szindarab(C, 0);
vector<int> szinek(N, 0);
int K = 0, M = INT_MAX;
int L = 0;
for(int i = 0; i < N; ++i)
{
cin >> szinek[i];
K += (szindarab[szinek[i]] == 0);
szindarab[szinek[i]]++;
if(K != C) continue;
while(K == C)
{
szindarab[szinek[L]]--;
K -= (szindarab[szinek[L]] == 0);
L++;
}
M = min(M, i-L);
}
cout << M+2 << "\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1976 KiB | ||||
2 | Accepted | 2ms | 2024 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 17ms | 3592 KiB | ||||
4 | Accepted | 17ms | 3784 KiB | ||||
5 | Accepted | 17ms | 3988 KiB | ||||
6 | Accepted | 2ms | 2720 KiB | ||||
7 | Accepted | 2ms | 2932 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 2ms | 3284 KiB | ||||
9 | Accepted | 2ms | 3344 KiB | ||||
10 | Accepted | 2ms | 3424 KiB | ||||
11 | Accepted | 2ms | 3420 KiB | ||||
12 | Accepted | 2ms | 3512 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 2ms | 3624 KiB | ||||
14 | Accepted | 2ms | 3744 KiB | ||||
15 | Accepted | 2ms | 3840 KiB | ||||
16 | Accepted | 2ms | 3744 KiB | ||||
17 | Accepted | 2ms | 3840 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 3ms | 4016 KiB | ||||
19 | Accepted | 3ms | 4312 KiB | ||||
20 | Accepted | 3ms | 4152 KiB | ||||
21 | Accepted | 2ms | 4236 KiB | ||||
22 | Accepted | 3ms | 4184 KiB | ||||
subtask6 | 30/30 | ||||||
23 | Accepted | 26ms | 7040 KiB | ||||
24 | Accepted | 19ms | 5484 KiB | ||||
25 | Accepted | 20ms | 5484 KiB | ||||
26 | Accepted | 23ms | 6152 KiB | ||||
27 | Accepted | 23ms | 6432 KiB | ||||
28 | Accepted | 20ms | 5516 KiB | ||||
29 | Accepted | 19ms | 5508 KiB | ||||
30 | Accepted | 16ms | 5512 KiB |