#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, m; cin >> n >> k >> m;
vector<int> a(n+1);
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 0; i < m; ++i){
int t; cin >> t;
if (t == 1) {
int p, v; cin >> p >> v;
a[p] = v;
} else{
int ans = n + 1;
vector<int> ncnt(k+1);
int cnt = 0;
int r = 1;
for (int l = 1; l <= n; ++l){
while (cnt < k && r <= n) {
ncnt[a[r]]++;
if (ncnt[a[r]] == 1) cnt++;
r++;
}
if (cnt < k) break;
ans = min(ans, r - l);
ncnt[a[l]]--;
if (ncnt[a[l]] == 0) cnt--;
}
if (ans == n+1) ans = -1;
cout << ans << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
212 KB |
Output is correct |
2 |
Correct |
6 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
212 KB |
Output is correct |
2 |
Correct |
10 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
316 KB |
Output is correct |
2 |
Correct |
11 ms |
224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1860 ms |
532 KB |
Output is correct |
2 |
Correct |
1960 ms |
1148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3062 ms |
660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3072 ms |
816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3082 ms |
676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3060 ms |
764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3086 ms |
756 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |