# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55413 | 2018-07-07T08:27:51 Z | 강태규(#1543) | Toilets (JOI16_toilets) | C++11 | 4 ms | 868 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; int n, m; char str[200001]; int main() { scanf("%d%d", &n, &m); scanf("%s%d", str); int mn = 0, sum = 0; for (int i = strlen(str); i--; ) { sum += (str[i] == 'M' ? -1 : 1); mn = min(mn, sum); } if (sum < 0) printf("-1\n"); else if (mn > -2) printf("0\n"); else printf("%d\n", -(mn + 1)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 436 KB | Output is correct |
4 | Correct | 2 ms | 456 KB | Output is correct |
5 | Correct | 2 ms | 456 KB | Output is correct |
6 | Correct | 2 ms | 512 KB | Output is correct |
7 | Correct | 3 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 556 KB | Output is correct |
10 | Correct | 1 ms | 572 KB | Output is correct |
11 | Correct | 2 ms | 596 KB | Output is correct |
12 | Correct | 2 ms | 596 KB | Output is correct |
13 | Correct | 2 ms | 596 KB | Output is correct |
14 | Correct | 2 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 596 KB | Output is correct |
16 | Correct | 2 ms | 596 KB | Output is correct |
17 | Correct | 2 ms | 596 KB | Output is correct |
18 | Correct | 2 ms | 596 KB | Output is correct |
19 | Correct | 2 ms | 596 KB | Output is correct |
20 | Correct | 2 ms | 596 KB | Output is correct |
21 | Correct | 2 ms | 596 KB | Output is correct |
22 | Correct | 2 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 436 KB | Output is correct |
4 | Correct | 2 ms | 456 KB | Output is correct |
5 | Correct | 2 ms | 456 KB | Output is correct |
6 | Correct | 2 ms | 512 KB | Output is correct |
7 | Correct | 3 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 556 KB | Output is correct |
10 | Correct | 1 ms | 572 KB | Output is correct |
11 | Correct | 2 ms | 596 KB | Output is correct |
12 | Correct | 2 ms | 596 KB | Output is correct |
13 | Correct | 2 ms | 596 KB | Output is correct |
14 | Correct | 2 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 596 KB | Output is correct |
16 | Correct | 2 ms | 596 KB | Output is correct |
17 | Correct | 2 ms | 596 KB | Output is correct |
18 | Correct | 2 ms | 596 KB | Output is correct |
19 | Correct | 2 ms | 596 KB | Output is correct |
20 | Correct | 2 ms | 596 KB | Output is correct |
21 | Correct | 2 ms | 596 KB | Output is correct |
22 | Correct | 2 ms | 596 KB | Output is correct |
23 | Correct | 2 ms | 740 KB | Output is correct |
24 | Correct | 3 ms | 740 KB | Output is correct |
25 | Correct | 3 ms | 740 KB | Output is correct |
26 | Correct | 4 ms | 740 KB | Output is correct |
27 | Correct | 3 ms | 740 KB | Output is correct |
28 | Correct | 3 ms | 740 KB | Output is correct |
29 | Correct | 4 ms | 740 KB | Output is correct |
30 | Correct | 3 ms | 740 KB | Output is correct |
31 | Correct | 3 ms | 740 KB | Output is correct |
32 | Correct | 3 ms | 740 KB | Output is correct |
33 | Correct | 3 ms | 740 KB | Output is correct |
34 | Correct | 3 ms | 740 KB | Output is correct |
35 | Correct | 4 ms | 740 KB | Output is correct |
36 | Correct | 4 ms | 740 KB | Output is correct |
37 | Correct | 4 ms | 868 KB | Output is correct |
38 | Correct | 4 ms | 868 KB | Output is correct |
39 | Correct | 3 ms | 868 KB | Output is correct |
40 | Correct | 4 ms | 868 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 436 KB | Output is correct |
4 | Correct | 2 ms | 456 KB | Output is correct |
5 | Correct | 2 ms | 456 KB | Output is correct |
6 | Correct | 2 ms | 512 KB | Output is correct |
7 | Correct | 3 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 556 KB | Output is correct |
10 | Correct | 1 ms | 572 KB | Output is correct |
11 | Correct | 2 ms | 596 KB | Output is correct |
12 | Correct | 2 ms | 596 KB | Output is correct |
13 | Correct | 2 ms | 596 KB | Output is correct |
14 | Correct | 2 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 596 KB | Output is correct |
16 | Correct | 2 ms | 596 KB | Output is correct |
17 | Correct | 2 ms | 596 KB | Output is correct |
18 | Correct | 2 ms | 596 KB | Output is correct |
19 | Correct | 2 ms | 596 KB | Output is correct |
20 | Correct | 2 ms | 596 KB | Output is correct |
21 | Correct | 2 ms | 596 KB | Output is correct |
22 | Correct | 2 ms | 596 KB | Output is correct |
23 | Correct | 2 ms | 740 KB | Output is correct |
24 | Correct | 3 ms | 740 KB | Output is correct |
25 | Correct | 3 ms | 740 KB | Output is correct |
26 | Correct | 4 ms | 740 KB | Output is correct |
27 | Correct | 3 ms | 740 KB | Output is correct |
28 | Correct | 3 ms | 740 KB | Output is correct |
29 | Correct | 4 ms | 740 KB | Output is correct |
30 | Correct | 3 ms | 740 KB | Output is correct |
31 | Correct | 3 ms | 740 KB | Output is correct |
32 | Correct | 3 ms | 740 KB | Output is correct |
33 | Correct | 3 ms | 740 KB | Output is correct |
34 | Correct | 3 ms | 740 KB | Output is correct |
35 | Correct | 4 ms | 740 KB | Output is correct |
36 | Correct | 4 ms | 740 KB | Output is correct |
37 | Correct | 4 ms | 868 KB | Output is correct |
38 | Correct | 4 ms | 868 KB | Output is correct |
39 | Correct | 3 ms | 868 KB | Output is correct |
40 | Correct | 4 ms | 868 KB | Output is correct |
41 | Correct | 2 ms | 868 KB | Output is correct |
42 | Incorrect | 2 ms | 868 KB | Output isn't correct |
43 | Halted | 0 ms | 0 KB | - |