Submission #201339

#TimeUsernameProblemLanguageResultExecution timeMemory
201339parsa_mobedJJOOII 2 (JOI20_ho_t2)C++14
100 / 100
29 ms1144 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, inf = 1e9; deque <int> dq[3]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < 3; i++) for (int j = 0; j < k; j++) dq[i].push_back(-inf); int ans = 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...