Submission #276817

#TimeUsernameProblemLanguageResultExecution timeMemory
276817islingrJJOOII 2 (JOI20_ho_t2)C++17
100 / 100
9 ms768 KiB
#include <iostream> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, k, res = n; string s; cin >> n >> k >> s; for (int l = 0, j = 0, o = 0, i = 0, cj = 0, co = 0, ci = 0; l < n; ++l) { while (j < n && cj < k) { if (s[j] == 'J') ++cj; if (s[j] == 'O') --co; ++j; } while (o < n && co < k) { if (s[o] == 'O') ++co; if (s[o] == 'I') --ci; ++o; } while (i < n && ci < k) if (s[i++] == 'I') ++ci; if (ci != k) break; res = min(res, i - l - 3 * k); if (s[l] == 'J') --cj; } cout << (res < n ? res : -1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...