#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const int MAXN = 5010;
const int MAXK = 50;
int k;
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> k >> m;
int arr[n];
for(int i = 0;i<n;i++){
cin >> arr[i];
arr[i]--;
}
while(m--) {
int type;
cin >> type;
if(type == 1) {
int p, v;
cin >> p >> v;
v--;p--;
arr[p] = v;
}
else {
vector<int> mp(51, 0);
int p1 = 0, p2 = 0;
int mx = 0;
int ans = 1e9;
set<int> s;
mp[arr[0]]++;
for(int i = 0;i<=50;i++)s.insert(i);
s.erase(arr[0]);
while(p2 < n) {
mx = *(s.begin());
if(mx >= k) {
ans = min(ans, (int)p2-p1+1);
mp[arr[p1]]--;
if(mp[arr[p1]] == 0)s.insert(arr[p1]);
p1++;
}
else {
if(p2 < n-1){
mp[arr[p2+1]]++;
s.erase(arr[p2+1]);
}
p2++;
}
}
if(ans == 1e9)ans = -1;
cout << ans << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
328 KB |
Output is correct |
2 |
Correct |
13 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
344 KB |
Output is correct |
2 |
Correct |
17 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
364 KB |
Output is correct |
2 |
Correct |
25 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3085 ms |
540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3094 ms |
524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3092 ms |
468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3089 ms |
640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3063 ms |
544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3088 ms |
708 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3057 ms |
692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |