# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
693331 | 2023-02-02T20:22:45 Z | rainboy | Toilets (JOI16_toilets) | C | 21 ms | 1800 KB |
#include <stdio.h> #include <string.h> #define N 200000 long long max(long long a, long long b){ return a > b ? a : b; } int main() { int m; long long sum_, suf_; scanf("%*d%d", &m); sum_ = 0, suf_ = 0; while (m--) { static char cc[N + 1]; int n, i; long long k, sum, suf; scanf("%s%lld", cc, &k), n = strlen(cc); sum = suf = 0; for (i = 0; i < n; i++) { sum += cc[i] == 'M' ? 1 : -1; if ((suf += cc[i] == 'M' ? 1 : -1) < 0) suf = 0; } sum_ += sum * k, suf_ = max(suf + sum * k, max(sum * (k - 1), 0) + suf); } printf("%lld\n", sum_ > 0 ? -1 : (suf_ == 0 ? 0 : suf_ - 1)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 292 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 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 | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 288 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 300 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 292 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 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 | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 288 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 300 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 292 KB | Output is correct |
23 | Correct | 1 ms | 596 KB | Output is correct |
24 | Correct | 1 ms | 672 KB | Output is correct |
25 | Correct | 1 ms | 596 KB | Output is correct |
26 | Correct | 1 ms | 596 KB | Output is correct |
27 | Correct | 1 ms | 564 KB | Output is correct |
28 | Correct | 1 ms | 676 KB | Output is correct |
29 | Correct | 1 ms | 596 KB | Output is correct |
30 | Correct | 2 ms | 596 KB | Output is correct |
31 | Correct | 1 ms | 596 KB | Output is correct |
32 | Correct | 1 ms | 596 KB | Output is correct |
33 | Correct | 2 ms | 608 KB | Output is correct |
34 | Correct | 2 ms | 604 KB | Output is correct |
35 | Correct | 1 ms | 668 KB | Output is correct |
36 | Correct | 1 ms | 560 KB | Output is correct |
37 | Correct | 1 ms | 596 KB | Output is correct |
38 | Correct | 1 ms | 672 KB | Output is correct |
39 | Correct | 1 ms | 560 KB | Output is correct |
40 | Correct | 2 ms | 572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 292 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 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 | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 288 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 300 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 292 KB | Output is correct |
23 | Correct | 1 ms | 596 KB | Output is correct |
24 | Correct | 1 ms | 672 KB | Output is correct |
25 | Correct | 1 ms | 596 KB | Output is correct |
26 | Correct | 1 ms | 596 KB | Output is correct |
27 | Correct | 1 ms | 564 KB | Output is correct |
28 | Correct | 1 ms | 676 KB | Output is correct |
29 | Correct | 1 ms | 596 KB | Output is correct |
30 | Correct | 2 ms | 596 KB | Output is correct |
31 | Correct | 1 ms | 596 KB | Output is correct |
32 | Correct | 1 ms | 596 KB | Output is correct |
33 | Correct | 2 ms | 608 KB | Output is correct |
34 | Correct | 2 ms | 604 KB | Output is correct |
35 | Correct | 1 ms | 668 KB | Output is correct |
36 | Correct | 1 ms | 560 KB | Output is correct |
37 | Correct | 1 ms | 596 KB | Output is correct |
38 | Correct | 1 ms | 672 KB | Output is correct |
39 | Correct | 1 ms | 560 KB | Output is correct |
40 | Correct | 2 ms | 572 KB | Output is correct |
41 | Correct | 21 ms | 1800 KB | Output is correct |
42 | Incorrect | 21 ms | 1796 KB | Output isn't correct |
43 | Halted | 0 ms | 0 KB | - |