# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
520385 | 2022-01-29T18:23:37 Z | aris12345678 | JJOOII 2 (JOI20_ho_t2) | C++14 | 2000 ms | 808 KB |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); string s; cin >> s; int ans = INT_MAX; for(int i = 0; i < n; i++) { if(s[i] != 'J') continue; string t = ""; int m = 0; for(int j = i; j < n; j++) { if(m < k && s[j] == 'J') t += s[j], m++; if(m >= k && m < 2*k && s[j] == 'O') t += s[j], m++; if(m >= 2*k && m < 3*k && s[j] == 'I') t += s[j], m++; if(m == 3*k) { ans = min(ans, (j-i+1)-m); // cout << i << " " << j << ": " << t << "\n"; } } } if(ans == INT_MAX) printf("-1\n"); else printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 288 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 292 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 0 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 288 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 292 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 0 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 288 KB | Output is correct |
15 | Correct | 2 ms | 204 KB | Output is correct |
16 | Correct | 3 ms | 204 KB | Output is correct |
17 | Correct | 4 ms | 204 KB | Output is correct |
18 | Correct | 4 ms | 216 KB | Output is correct |
19 | Correct | 5 ms | 204 KB | Output is correct |
20 | Correct | 4 ms | 204 KB | Output is correct |
21 | Correct | 7 ms | 204 KB | Output is correct |
22 | Correct | 9 ms | 204 KB | Output is correct |
23 | Correct | 4 ms | 204 KB | Output is correct |
24 | Correct | 9 ms | 300 KB | Output is correct |
25 | Correct | 10 ms | 288 KB | Output is correct |
26 | Correct | 9 ms | 288 KB | Output is correct |
27 | Correct | 9 ms | 204 KB | Output is correct |
28 | Correct | 9 ms | 204 KB | Output is correct |
29 | Correct | 9 ms | 296 KB | Output is correct |
30 | Correct | 11 ms | 204 KB | Output is correct |
31 | Correct | 2 ms | 204 KB | Output is correct |
32 | Correct | 10 ms | 204 KB | Output is correct |
33 | Correct | 4 ms | 204 KB | Output is correct |
34 | Correct | 8 ms | 360 KB | Output is correct |
35 | Correct | 5 ms | 304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 288 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 292 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 0 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 288 KB | Output is correct |
15 | Correct | 2 ms | 204 KB | Output is correct |
16 | Correct | 3 ms | 204 KB | Output is correct |
17 | Correct | 4 ms | 204 KB | Output is correct |
18 | Correct | 4 ms | 216 KB | Output is correct |
19 | Correct | 5 ms | 204 KB | Output is correct |
20 | Correct | 4 ms | 204 KB | Output is correct |
21 | Correct | 7 ms | 204 KB | Output is correct |
22 | Correct | 9 ms | 204 KB | Output is correct |
23 | Correct | 4 ms | 204 KB | Output is correct |
24 | Correct | 9 ms | 300 KB | Output is correct |
25 | Correct | 10 ms | 288 KB | Output is correct |
26 | Correct | 9 ms | 288 KB | Output is correct |
27 | Correct | 9 ms | 204 KB | Output is correct |
28 | Correct | 9 ms | 204 KB | Output is correct |
29 | Correct | 9 ms | 296 KB | Output is correct |
30 | Correct | 11 ms | 204 KB | Output is correct |
31 | Correct | 2 ms | 204 KB | Output is correct |
32 | Correct | 10 ms | 204 KB | Output is correct |
33 | Correct | 4 ms | 204 KB | Output is correct |
34 | Correct | 8 ms | 360 KB | Output is correct |
35 | Correct | 5 ms | 304 KB | Output is correct |
36 | Execution timed out | 2053 ms | 808 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |