# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
55403 | 2018-07-07T07:51:04 Z | 김세빈(#1545) | Toilets (JOI16_toilets) | C++11 | 37 ms | 6372 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; char str[202020]; ll K[202020], S[202020]; ll T[606060], L[606060]; ll n, k, f, m; bool check(ll k) { ll i, a, b, s; for(i=0;i<=n+n;i++) S[i] = 0; a = b = s = 0; for(i=0;i<n+n;i++){ if(a < m && ((~i & 1) || f - b >= m - (a+1)) && (K[a+1] < b+1 || s + S[b+1] < k)){ S[b+1] ++; S[K[a+1]+1] --; a ++; } else if(b < f && ((~i & 1) || f - (b+1) >= m - a)){ b ++; s += S[b]; } else return 0; } return 1; } 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 ++; K[m] = f; } } if(f < m){ printf("-1\n"); return 0; } for(s=0,e=n+n;s<=e;){ if(check(s+e>>1)) e = (s+e>>1) - 1; else s = (s+e>>1) + 1; } printf("%lld\n", e + 1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 3 ms | 508 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 3 ms | 544 KB | Output is correct |
8 | Correct | 4 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 0 ms | 544 KB | Output is correct |
11 | Correct | 4 ms | 584 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 2 ms | 620 KB | Output is correct |
14 | Correct | 2 ms | 620 KB | Output is correct |
15 | Correct | 2 ms | 620 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 624 KB | Output is correct |
18 | Correct | 2 ms | 636 KB | Output is correct |
19 | Correct | 2 ms | 636 KB | Output is correct |
20 | Correct | 2 ms | 636 KB | Output is correct |
21 | Correct | 2 ms | 636 KB | Output is correct |
22 | Correct | 2 ms | 636 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 3 ms | 508 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 3 ms | 544 KB | Output is correct |
8 | Correct | 4 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 0 ms | 544 KB | Output is correct |
11 | Correct | 4 ms | 584 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 2 ms | 620 KB | Output is correct |
14 | Correct | 2 ms | 620 KB | Output is correct |
15 | Correct | 2 ms | 620 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 624 KB | Output is correct |
18 | Correct | 2 ms | 636 KB | Output is correct |
19 | Correct | 2 ms | 636 KB | Output is correct |
20 | Correct | 2 ms | 636 KB | Output is correct |
21 | Correct | 2 ms | 636 KB | Output is correct |
22 | Correct | 2 ms | 636 KB | Output is correct |
23 | Correct | 23 ms | 3068 KB | Output is correct |
24 | Correct | 29 ms | 3324 KB | Output is correct |
25 | Correct | 27 ms | 3424 KB | Output is correct |
26 | Correct | 19 ms | 3424 KB | Output is correct |
27 | Correct | 4 ms | 3424 KB | Output is correct |
28 | Correct | 32 ms | 4028 KB | Output is correct |
29 | Correct | 29 ms | 4168 KB | Output is correct |
30 | Correct | 25 ms | 4680 KB | Output is correct |
31 | Correct | 32 ms | 4848 KB | Output is correct |
32 | Correct | 27 ms | 5036 KB | Output is correct |
33 | Correct | 4 ms | 5036 KB | Output is correct |
34 | Correct | 21 ms | 5036 KB | Output is correct |
35 | Correct | 35 ms | 5668 KB | Output is correct |
36 | Correct | 37 ms | 5816 KB | Output is correct |
37 | Correct | 15 ms | 5816 KB | Output is correct |
38 | Correct | 4 ms | 5816 KB | Output is correct |
39 | Correct | 27 ms | 6296 KB | Output is correct |
40 | Correct | 26 ms | 6372 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 3 ms | 508 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 3 ms | 544 KB | Output is correct |
8 | Correct | 4 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 0 ms | 544 KB | Output is correct |
11 | Correct | 4 ms | 584 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 2 ms | 620 KB | Output is correct |
14 | Correct | 2 ms | 620 KB | Output is correct |
15 | Correct | 2 ms | 620 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 624 KB | Output is correct |
18 | Correct | 2 ms | 636 KB | Output is correct |
19 | Correct | 2 ms | 636 KB | Output is correct |
20 | Correct | 2 ms | 636 KB | Output is correct |
21 | Correct | 2 ms | 636 KB | Output is correct |
22 | Correct | 2 ms | 636 KB | Output is correct |
23 | Correct | 23 ms | 3068 KB | Output is correct |
24 | Correct | 29 ms | 3324 KB | Output is correct |
25 | Correct | 27 ms | 3424 KB | Output is correct |
26 | Correct | 19 ms | 3424 KB | Output is correct |
27 | Correct | 4 ms | 3424 KB | Output is correct |
28 | Correct | 32 ms | 4028 KB | Output is correct |
29 | Correct | 29 ms | 4168 KB | Output is correct |
30 | Correct | 25 ms | 4680 KB | Output is correct |
31 | Correct | 32 ms | 4848 KB | Output is correct |
32 | Correct | 27 ms | 5036 KB | Output is correct |
33 | Correct | 4 ms | 5036 KB | Output is correct |
34 | Correct | 21 ms | 5036 KB | Output is correct |
35 | Correct | 35 ms | 5668 KB | Output is correct |
36 | Correct | 37 ms | 5816 KB | Output is correct |
37 | Correct | 15 ms | 5816 KB | Output is correct |
38 | Correct | 4 ms | 5816 KB | Output is correct |
39 | Correct | 27 ms | 6296 KB | Output is correct |
40 | Correct | 26 ms | 6372 KB | Output is correct |
41 | Incorrect | 2 ms | 6372 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |