# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
53710 | 2018-07-01T05:38:48 Z | ainta(#1540) | Toilets (JOI16_toilets) | C++11 | 39 ms | 5660 KB |
#include<cstdio> #include<algorithm> #include<string> using namespace std; long long L; int n; char p[201000]; struct point { string T; int s, M; long long K; }w[101000]; long long ss; int main() { int i, j; scanf("%lld%d", &L, &n); long long M = 0; for (i = 1; i <= n; i++) { scanf("%s", p); scanf("%lld", &w[i].K); w[i].s = w[i].M = 0; for (j = 0; p[j]; j++) { if (p[j] == 'F')w[i].s++; else w[i].s--; w[i].M = max(w[i].M, w[i].s); } M = max(M, max(ss + w[i].M, ss + w[i].s*(w[i].K - 1) + w[i].M)); ss += w[i].s*w[i].K; } if (ss < 0) { puts("-1"); return 0; } if (M < ss + 1)puts("0"); else printf("%lld\n", M - (ss + 1)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 6 ms | 5096 KB | Output is correct |
3 | Correct | 8 ms | 5304 KB | Output is correct |
4 | Correct | 7 ms | 5304 KB | Output is correct |
5 | Correct | 7 ms | 5304 KB | Output is correct |
6 | Correct | 7 ms | 5304 KB | Output is correct |
7 | Correct | 6 ms | 5336 KB | Output is correct |
8 | Correct | 7 ms | 5360 KB | Output is correct |
9 | Correct | 7 ms | 5360 KB | Output is correct |
10 | Correct | 7 ms | 5360 KB | Output is correct |
11 | Correct | 8 ms | 5360 KB | Output is correct |
12 | Correct | 6 ms | 5360 KB | Output is correct |
13 | Correct | 6 ms | 5360 KB | Output is correct |
14 | Correct | 8 ms | 5360 KB | Output is correct |
15 | Correct | 6 ms | 5412 KB | Output is correct |
16 | Correct | 6 ms | 5412 KB | Output is correct |
17 | Correct | 6 ms | 5412 KB | Output is correct |
18 | Correct | 6 ms | 5412 KB | Output is correct |
19 | Correct | 5 ms | 5412 KB | Output is correct |
20 | Correct | 6 ms | 5412 KB | Output is correct |
21 | Correct | 5 ms | 5412 KB | Output is correct |
22 | Correct | 6 ms | 5412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 6 ms | 5096 KB | Output is correct |
3 | Correct | 8 ms | 5304 KB | Output is correct |
4 | Correct | 7 ms | 5304 KB | Output is correct |
5 | Correct | 7 ms | 5304 KB | Output is correct |
6 | Correct | 7 ms | 5304 KB | Output is correct |
7 | Correct | 6 ms | 5336 KB | Output is correct |
8 | Correct | 7 ms | 5360 KB | Output is correct |
9 | Correct | 7 ms | 5360 KB | Output is correct |
10 | Correct | 7 ms | 5360 KB | Output is correct |
11 | Correct | 8 ms | 5360 KB | Output is correct |
12 | Correct | 6 ms | 5360 KB | Output is correct |
13 | Correct | 6 ms | 5360 KB | Output is correct |
14 | Correct | 8 ms | 5360 KB | Output is correct |
15 | Correct | 6 ms | 5412 KB | Output is correct |
16 | Correct | 6 ms | 5412 KB | Output is correct |
17 | Correct | 6 ms | 5412 KB | Output is correct |
18 | Correct | 6 ms | 5412 KB | Output is correct |
19 | Correct | 5 ms | 5412 KB | Output is correct |
20 | Correct | 6 ms | 5412 KB | Output is correct |
21 | Correct | 5 ms | 5412 KB | Output is correct |
22 | Correct | 6 ms | 5412 KB | Output is correct |
23 | Correct | 8 ms | 5576 KB | Output is correct |
24 | Correct | 8 ms | 5576 KB | Output is correct |
25 | Correct | 8 ms | 5656 KB | Output is correct |
26 | Correct | 7 ms | 5656 KB | Output is correct |
27 | Correct | 9 ms | 5656 KB | Output is correct |
28 | Correct | 8 ms | 5656 KB | Output is correct |
29 | Correct | 10 ms | 5656 KB | Output is correct |
30 | Correct | 7 ms | 5660 KB | Output is correct |
31 | Correct | 8 ms | 5660 KB | Output is correct |
32 | Correct | 8 ms | 5660 KB | Output is correct |
33 | Correct | 7 ms | 5660 KB | Output is correct |
34 | Correct | 7 ms | 5660 KB | Output is correct |
35 | Correct | 9 ms | 5660 KB | Output is correct |
36 | Correct | 8 ms | 5660 KB | Output is correct |
37 | Correct | 7 ms | 5660 KB | Output is correct |
38 | Correct | 7 ms | 5660 KB | Output is correct |
39 | Correct | 9 ms | 5660 KB | Output is correct |
40 | Correct | 7 ms | 5660 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 6 ms | 5096 KB | Output is correct |
3 | Correct | 8 ms | 5304 KB | Output is correct |
4 | Correct | 7 ms | 5304 KB | Output is correct |
5 | Correct | 7 ms | 5304 KB | Output is correct |
6 | Correct | 7 ms | 5304 KB | Output is correct |
7 | Correct | 6 ms | 5336 KB | Output is correct |
8 | Correct | 7 ms | 5360 KB | Output is correct |
9 | Correct | 7 ms | 5360 KB | Output is correct |
10 | Correct | 7 ms | 5360 KB | Output is correct |
11 | Correct | 8 ms | 5360 KB | Output is correct |
12 | Correct | 6 ms | 5360 KB | Output is correct |
13 | Correct | 6 ms | 5360 KB | Output is correct |
14 | Correct | 8 ms | 5360 KB | Output is correct |
15 | Correct | 6 ms | 5412 KB | Output is correct |
16 | Correct | 6 ms | 5412 KB | Output is correct |
17 | Correct | 6 ms | 5412 KB | Output is correct |
18 | Correct | 6 ms | 5412 KB | Output is correct |
19 | Correct | 5 ms | 5412 KB | Output is correct |
20 | Correct | 6 ms | 5412 KB | Output is correct |
21 | Correct | 5 ms | 5412 KB | Output is correct |
22 | Correct | 6 ms | 5412 KB | Output is correct |
23 | Correct | 8 ms | 5576 KB | Output is correct |
24 | Correct | 8 ms | 5576 KB | Output is correct |
25 | Correct | 8 ms | 5656 KB | Output is correct |
26 | Correct | 7 ms | 5656 KB | Output is correct |
27 | Correct | 9 ms | 5656 KB | Output is correct |
28 | Correct | 8 ms | 5656 KB | Output is correct |
29 | Correct | 10 ms | 5656 KB | Output is correct |
30 | Correct | 7 ms | 5660 KB | Output is correct |
31 | Correct | 8 ms | 5660 KB | Output is correct |
32 | Correct | 8 ms | 5660 KB | Output is correct |
33 | Correct | 7 ms | 5660 KB | Output is correct |
34 | Correct | 7 ms | 5660 KB | Output is correct |
35 | Correct | 9 ms | 5660 KB | Output is correct |
36 | Correct | 8 ms | 5660 KB | Output is correct |
37 | Correct | 7 ms | 5660 KB | Output is correct |
38 | Correct | 7 ms | 5660 KB | Output is correct |
39 | Correct | 9 ms | 5660 KB | Output is correct |
40 | Correct | 7 ms | 5660 KB | Output is correct |
41 | Correct | 39 ms | 5660 KB | Output is correct |
42 | Correct | 37 ms | 5660 KB | Output is correct |
43 | Correct | 7 ms | 5660 KB | Output is correct |
44 | Correct | 6 ms | 5660 KB | Output is correct |
45 | Correct | 7 ms | 5660 KB | Output is correct |
46 | Correct | 24 ms | 5660 KB | Output is correct |
47 | Correct | 8 ms | 5660 KB | Output is correct |
48 | Correct | 7 ms | 5660 KB | Output is correct |
49 | Correct | 8 ms | 5660 KB | Output is correct |
50 | Correct | 7 ms | 5660 KB | Output is correct |
51 | Correct | 12 ms | 5660 KB | Output is correct |
52 | Correct | 36 ms | 5660 KB | Output is correct |
53 | Correct | 37 ms | 5660 KB | Output is correct |
54 | Correct | 33 ms | 5660 KB | Output is correct |
55 | Correct | 7 ms | 5660 KB | Output is correct |
56 | Correct | 8 ms | 5660 KB | Output is correct |