Submission #201919

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2019192020-02-12 20:33:09kuroniJJOOII 2 (JOI20_ho_t2)C++17
100 / 100
8 ms508 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, k, ans = N, j = 1, o = 1, i = 1, cj = 0, co = 0, ci = 0;
char s[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k >> (s + 1);
for (int l = 1; l <= n; l++) {
for (; j <= n && cj < k; j++) {
cj += (s[j] == 'J');
co -= (s[j] == 'O');
}
for (; o <= n && co < k; o++) {
co += (s[o] == 'O');
ci -= (s[o] == 'I');
}
for (; i <= n && ci < k; i++) {
ci += (s[i] == 'I');
}
if (cj < k || co < k || ci < k) {
break;
} else {
ans = min(ans, i - l);
}
cj -= (s[l] == 'J');
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...