# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
829046 |
2023-08-18T02:58:02 Z |
vjudge1 |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
6 ms |
872 KB |
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define fi first
#define se second
ll n, k, ans, j, o, i, cntj, cnto, cnti;
ll a[101];
string joi; //ironically, I'm not joiful.
int main() {
fastio;
cin >> n >> k >> joi;
ans = 1e18;
for (int t = 0; t < n; t++) {
while (j < n && cntj < k) {
if (joi[j] == 'J') {
cntj++;
}
if (joi[j] == 'O') {
cnto--;
}
j++;
}
while (o < n && cnto < k) {
if (joi[o] == 'O') {
cnto++;
}
if (joi[o] == 'I') {
cnti--;
}
o++;
}
while (i < n && cnti < k) {
if (joi[i] == 'I') {
cnti++;
}
i++;
}
if (cnti != k) {
break;
}
ans = min(ans, i - t - 3*k);
if (joi[t] == 'J') {
cntj--;
}
}
if (ans < n) {
cout << ans << endl;
} else {
cout << -1 << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
0 ms |
316 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
0 ms |
316 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
316 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
0 ms |
316 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
316 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
320 KB |
Output is correct |
36 |
Correct |
5 ms |
848 KB |
Output is correct |
37 |
Correct |
5 ms |
868 KB |
Output is correct |
38 |
Correct |
5 ms |
848 KB |
Output is correct |
39 |
Correct |
5 ms |
852 KB |
Output is correct |
40 |
Correct |
3 ms |
872 KB |
Output is correct |
41 |
Correct |
4 ms |
852 KB |
Output is correct |
42 |
Correct |
6 ms |
836 KB |
Output is correct |
43 |
Correct |
2 ms |
596 KB |
Output is correct |
44 |
Correct |
2 ms |
736 KB |
Output is correct |
45 |
Correct |
3 ms |
868 KB |
Output is correct |
46 |
Correct |
3 ms |
840 KB |
Output is correct |
47 |
Correct |
3 ms |
844 KB |
Output is correct |
48 |
Correct |
4 ms |
852 KB |
Output is correct |
49 |
Correct |
2 ms |
724 KB |
Output is correct |
50 |
Correct |
3 ms |
840 KB |
Output is correct |
51 |
Correct |
3 ms |
868 KB |
Output is correct |
52 |
Correct |
3 ms |
852 KB |
Output is correct |
53 |
Correct |
4 ms |
852 KB |
Output is correct |
54 |
Correct |
2 ms |
852 KB |
Output is correct |
55 |
Correct |
2 ms |
852 KB |
Output is correct |
56 |
Correct |
2 ms |
852 KB |
Output is correct |