Submission #555554

#TimeUsernameProblemLanguageResultExecution timeMemory
555554fuad27Nekameleoni (COCI15_nekameleoni)C++17
0 / 140
16 ms1224 KiB
#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 { map<int,int> mp; int p1 = 0, p2 = 0; int mx = 0; int ans = 1e9; mp[arr[0]]++; if(arr[0] == 0)mx = 1; while(p2 < n) { if(mx >= k) { ans = min(ans, (int)p2-p1+1); mp[arr[p1]]--; if(mp[arr[p1]] == 0)mx = p1; p1++; } else { if(p2 < n-1)mp[arr[p2+1]]++; while(mp[mx] > 0)mx++; p2++; } } if(ans == 1e9)ans = -1; cout << ans << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...