Submission #951143

#TimeUsernameProblemLanguageResultExecution timeMemory
951143starJJOOII 2 (JOI20_ho_t2)C++14
100 / 100
12 ms1372 KiB
#include <bits/stdc++.h> using namespace std; int N=200005, inf=1000000000; int n, k, ans; deque<int> dq[3]; int main() { cin >> n >> k; ans=inf; for (int i=0; i<3; i++) for (int j=0; j<k; j++) dq[i].push_back(-inf); for (int i=0; i<n; i++) { char c; cin >> c; if (c == 'J') dq[0].pop_back(), dq[0].push_front(i); if (c == 'O') dq[1].pop_back(), dq[1].push_front(dq[0].back()); if (c == 'I') dq[2].pop_back(), dq[2].push_front(dq[1].back()); ans=min(ans, i-dq[2][k-1]+1); } cout << (ans>=inf ? -1 : ans-3*k) << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...