11670 | 2024-11-04 18:20:59 | bzy | Karácsonyi égők | cpp17 | Time limit exceeded 70/100 | 1.6s | 1968 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n, c; cin >> n >> c;
vector <int> L(n);
for(int i = 0; i < n; i++) cin >> L[i];
vector <int> A(c, 0);
int ans = n;
int l = 0, r = 0;
while(r < n){
A[L[r]]++;
if(!count(A.begin(), A.end(), 0)){
while(A[L[l]]-1 > 0){
A[L[l]]--;
l++;
}
ans = min(ans, r - l + 1);
}
r++;
}
cout << ans;
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 | 1120 KiB | ||||
5 | Accepted | 37ms | 1056 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 | 508 KiB | ||||
12 | Accepted | 1ms | 524 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 1ms | 340 KiB | ||||
14 | Accepted | 1ms | 320 KiB | ||||
15 | Accepted | 1ms | 320 KiB | ||||
16 | Accepted | 1ms | 508 KiB | ||||
17 | Accepted | 1ms | 372 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 17ms | 432 KiB | ||||
19 | Accepted | 4ms | 320 KiB | ||||
20 | Accepted | 4ms | 320 KiB | ||||
21 | Accepted | 2ms | 320 KiB | ||||
22 | Accepted | 2ms | 320 KiB | ||||
subtask6 | 0/30 | ||||||
23 | Time limit exceeded | 1.6s | 1968 KiB | ||||
24 | Accepted | 115ms | 1080 KiB | ||||
25 | Accepted | 305ms | 1080 KiB | ||||
26 | Time limit exceeded | 1.6s | 1200 KiB | ||||
27 | Time limit exceeded | 1.58s | 1340 KiB | ||||
28 | Accepted | 303ms | 1080 KiB | ||||
29 | Accepted | 114ms | 1080 KiB | ||||
30 | Accepted | 37ms | 1080 KiB |