# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
55416 | 2018-07-07T08:45:53 Z | 김세빈(#1545) | Toilets (JOI16_toilets) | C++11 | 8 ms | 892 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; char str[202020]; ll n, k, f, m, ans1, ans2; int main() { ll i, s, e; scanf("%lld%lld", &n, &k); if(k > 1) return 0; scanf("%s", str); for(i=0;i<n+n;i++){ if(str[i] == 'F') f ++; else m ++; } if(f < m){ printf("-1\n"); return 0; } f = m = 0; for(i=n+n-1;i>=0;i--){ if(str[i] == 'F') f ++; else m ++; if(i & 1){ if(m - f & 1) ans1 = max(ans1, m - f); else ans1 = max(ans1, m - f + 1); } else{ if(m - f & 1) ans2 = max(ans2, m - f + 1); else ans2 = max(ans2, m - f); } } printf("%lld\n", min(ans1, ans2)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 3 ms | 596 KB | Output is correct |
9 | Correct | 3 ms | 608 KB | Output is correct |
10 | Correct | 2 ms | 608 KB | Output is correct |
11 | Correct | 2 ms | 628 KB | Output is correct |
12 | Correct | 2 ms | 628 KB | Output is correct |
13 | Correct | 2 ms | 628 KB | Output is correct |
14 | Correct | 2 ms | 628 KB | Output is correct |
15 | Correct | 3 ms | 628 KB | Output is correct |
16 | Correct | 2 ms | 628 KB | Output is correct |
17 | Correct | 3 ms | 628 KB | Output is correct |
18 | Correct | 3 ms | 628 KB | Output is correct |
19 | Correct | 3 ms | 628 KB | Output is correct |
20 | Correct | 2 ms | 628 KB | Output is correct |
21 | Correct | 2 ms | 628 KB | Output is correct |
22 | Correct | 3 ms | 628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 3 ms | 596 KB | Output is correct |
9 | Correct | 3 ms | 608 KB | Output is correct |
10 | Correct | 2 ms | 608 KB | Output is correct |
11 | Correct | 2 ms | 628 KB | Output is correct |
12 | Correct | 2 ms | 628 KB | Output is correct |
13 | Correct | 2 ms | 628 KB | Output is correct |
14 | Correct | 2 ms | 628 KB | Output is correct |
15 | Correct | 3 ms | 628 KB | Output is correct |
16 | Correct | 2 ms | 628 KB | Output is correct |
17 | Correct | 3 ms | 628 KB | Output is correct |
18 | Correct | 3 ms | 628 KB | Output is correct |
19 | Correct | 3 ms | 628 KB | Output is correct |
20 | Correct | 2 ms | 628 KB | Output is correct |
21 | Correct | 2 ms | 628 KB | Output is correct |
22 | Correct | 3 ms | 628 KB | Output is correct |
23 | Correct | 7 ms | 764 KB | Output is correct |
24 | Correct | 6 ms | 764 KB | Output is correct |
25 | Correct | 7 ms | 812 KB | Output is correct |
26 | Correct | 4 ms | 812 KB | Output is correct |
27 | Correct | 3 ms | 812 KB | Output is correct |
28 | Correct | 7 ms | 812 KB | Output is correct |
29 | Correct | 5 ms | 836 KB | Output is correct |
30 | Correct | 5 ms | 836 KB | Output is correct |
31 | Correct | 6 ms | 836 KB | Output is correct |
32 | Correct | 6 ms | 892 KB | Output is correct |
33 | Correct | 3 ms | 892 KB | Output is correct |
34 | Correct | 4 ms | 892 KB | Output is correct |
35 | Correct | 7 ms | 892 KB | Output is correct |
36 | Correct | 8 ms | 892 KB | Output is correct |
37 | Correct | 5 ms | 892 KB | Output is correct |
38 | Correct | 5 ms | 892 KB | Output is correct |
39 | Correct | 5 ms | 892 KB | Output is correct |
40 | Correct | 6 ms | 892 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 3 ms | 596 KB | Output is correct |
9 | Correct | 3 ms | 608 KB | Output is correct |
10 | Correct | 2 ms | 608 KB | Output is correct |
11 | Correct | 2 ms | 628 KB | Output is correct |
12 | Correct | 2 ms | 628 KB | Output is correct |
13 | Correct | 2 ms | 628 KB | Output is correct |
14 | Correct | 2 ms | 628 KB | Output is correct |
15 | Correct | 3 ms | 628 KB | Output is correct |
16 | Correct | 2 ms | 628 KB | Output is correct |
17 | Correct | 3 ms | 628 KB | Output is correct |
18 | Correct | 3 ms | 628 KB | Output is correct |
19 | Correct | 3 ms | 628 KB | Output is correct |
20 | Correct | 2 ms | 628 KB | Output is correct |
21 | Correct | 2 ms | 628 KB | Output is correct |
22 | Correct | 3 ms | 628 KB | Output is correct |
23 | Correct | 7 ms | 764 KB | Output is correct |
24 | Correct | 6 ms | 764 KB | Output is correct |
25 | Correct | 7 ms | 812 KB | Output is correct |
26 | Correct | 4 ms | 812 KB | Output is correct |
27 | Correct | 3 ms | 812 KB | Output is correct |
28 | Correct | 7 ms | 812 KB | Output is correct |
29 | Correct | 5 ms | 836 KB | Output is correct |
30 | Correct | 5 ms | 836 KB | Output is correct |
31 | Correct | 6 ms | 836 KB | Output is correct |
32 | Correct | 6 ms | 892 KB | Output is correct |
33 | Correct | 3 ms | 892 KB | Output is correct |
34 | Correct | 4 ms | 892 KB | Output is correct |
35 | Correct | 7 ms | 892 KB | Output is correct |
36 | Correct | 8 ms | 892 KB | Output is correct |
37 | Correct | 5 ms | 892 KB | Output is correct |
38 | Correct | 5 ms | 892 KB | Output is correct |
39 | Correct | 5 ms | 892 KB | Output is correct |
40 | Correct | 6 ms | 892 KB | Output is correct |
41 | Incorrect | 2 ms | 892 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |