# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55431 | 2018-07-07T09:31:29 Z | 내가진짜뚜룹뚭스(#2073) | Toilets (JOI16_toilets) | C++11 | 36 ms | 824 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, m, INF = 1LL<<60; char str[200100]; int main() { scanf("%lld%lld",&n,&m); int i, j; ll ap = 0, ans = 0; for (i=0;i<m;i++) { ll k; scanf(" %s%lld",str,&k); ll p = 0, mini = 0; int len = strlen(str); for (j=0;j<len;j++) { p+=(str[j]=='M'?1:-1); mini = min(mini,p); } ans = min(ans,min(ap+mini,ap+p*(k-1)+mini)); ap += p*k; } if (ap>0) { printf("-1\n"); return 0; } if (ans==ap) { printf("0\n"); return 0; } printf("%lld\n",ap-1-ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 392 KB | Output is correct |
4 | Correct | 2 ms | 392 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 476 KB | Output is correct |
7 | Correct | 2 ms | 496 KB | Output is correct |
8 | Correct | 2 ms | 496 KB | Output is correct |
9 | Correct | 3 ms | 496 KB | Output is correct |
10 | Correct | 2 ms | 496 KB | Output is correct |
11 | Correct | 2 ms | 496 KB | Output is correct |
12 | Correct | 2 ms | 496 KB | Output is correct |
13 | Correct | 2 ms | 496 KB | Output is correct |
14 | Correct | 3 ms | 548 KB | Output is correct |
15 | Correct | 2 ms | 568 KB | Output is correct |
16 | Correct | 2 ms | 688 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 3 ms | 688 KB | Output is correct |
21 | Correct | 3 ms | 688 KB | Output is correct |
22 | Correct | 2 ms | 688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 392 KB | Output is correct |
4 | Correct | 2 ms | 392 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 476 KB | Output is correct |
7 | Correct | 2 ms | 496 KB | Output is correct |
8 | Correct | 2 ms | 496 KB | Output is correct |
9 | Correct | 3 ms | 496 KB | Output is correct |
10 | Correct | 2 ms | 496 KB | Output is correct |
11 | Correct | 2 ms | 496 KB | Output is correct |
12 | Correct | 2 ms | 496 KB | Output is correct |
13 | Correct | 2 ms | 496 KB | Output is correct |
14 | Correct | 3 ms | 548 KB | Output is correct |
15 | Correct | 2 ms | 568 KB | Output is correct |
16 | Correct | 2 ms | 688 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 3 ms | 688 KB | Output is correct |
21 | Correct | 3 ms | 688 KB | Output is correct |
22 | Correct | 2 ms | 688 KB | Output is correct |
23 | Correct | 3 ms | 748 KB | Output is correct |
24 | Correct | 3 ms | 752 KB | Output is correct |
25 | Correct | 4 ms | 752 KB | Output is correct |
26 | Correct | 3 ms | 752 KB | Output is correct |
27 | Correct | 4 ms | 752 KB | Output is correct |
28 | Correct | 4 ms | 824 KB | Output is correct |
29 | Correct | 3 ms | 824 KB | Output is correct |
30 | Correct | 4 ms | 824 KB | Output is correct |
31 | Correct | 4 ms | 824 KB | Output is correct |
32 | Correct | 5 ms | 824 KB | Output is correct |
33 | Correct | 3 ms | 824 KB | Output is correct |
34 | Correct | 4 ms | 824 KB | Output is correct |
35 | Correct | 4 ms | 824 KB | Output is correct |
36 | Correct | 3 ms | 824 KB | Output is correct |
37 | Correct | 4 ms | 824 KB | Output is correct |
38 | Correct | 4 ms | 824 KB | Output is correct |
39 | Correct | 4 ms | 824 KB | Output is correct |
40 | Correct | 4 ms | 824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 392 KB | Output is correct |
4 | Correct | 2 ms | 392 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 2 ms | 476 KB | Output is correct |
7 | Correct | 2 ms | 496 KB | Output is correct |
8 | Correct | 2 ms | 496 KB | Output is correct |
9 | Correct | 3 ms | 496 KB | Output is correct |
10 | Correct | 2 ms | 496 KB | Output is correct |
11 | Correct | 2 ms | 496 KB | Output is correct |
12 | Correct | 2 ms | 496 KB | Output is correct |
13 | Correct | 2 ms | 496 KB | Output is correct |
14 | Correct | 3 ms | 548 KB | Output is correct |
15 | Correct | 2 ms | 568 KB | Output is correct |
16 | Correct | 2 ms | 688 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 3 ms | 688 KB | Output is correct |
21 | Correct | 3 ms | 688 KB | Output is correct |
22 | Correct | 2 ms | 688 KB | Output is correct |
23 | Correct | 3 ms | 748 KB | Output is correct |
24 | Correct | 3 ms | 752 KB | Output is correct |
25 | Correct | 4 ms | 752 KB | Output is correct |
26 | Correct | 3 ms | 752 KB | Output is correct |
27 | Correct | 4 ms | 752 KB | Output is correct |
28 | Correct | 4 ms | 824 KB | Output is correct |
29 | Correct | 3 ms | 824 KB | Output is correct |
30 | Correct | 4 ms | 824 KB | Output is correct |
31 | Correct | 4 ms | 824 KB | Output is correct |
32 | Correct | 5 ms | 824 KB | Output is correct |
33 | Correct | 3 ms | 824 KB | Output is correct |
34 | Correct | 4 ms | 824 KB | Output is correct |
35 | Correct | 4 ms | 824 KB | Output is correct |
36 | Correct | 3 ms | 824 KB | Output is correct |
37 | Correct | 4 ms | 824 KB | Output is correct |
38 | Correct | 4 ms | 824 KB | Output is correct |
39 | Correct | 4 ms | 824 KB | Output is correct |
40 | Correct | 4 ms | 824 KB | Output is correct |
41 | Correct | 30 ms | 824 KB | Output is correct |
42 | Correct | 35 ms | 824 KB | Output is correct |
43 | Correct | 2 ms | 824 KB | Output is correct |
44 | Correct | 3 ms | 824 KB | Output is correct |
45 | Correct | 2 ms | 824 KB | Output is correct |
46 | Correct | 8 ms | 824 KB | Output is correct |
47 | Correct | 5 ms | 824 KB | Output is correct |
48 | Correct | 3 ms | 824 KB | Output is correct |
49 | Correct | 3 ms | 824 KB | Output is correct |
50 | Correct | 4 ms | 824 KB | Output is correct |
51 | Correct | 6 ms | 824 KB | Output is correct |
52 | Correct | 36 ms | 824 KB | Output is correct |
53 | Correct | 32 ms | 824 KB | Output is correct |
54 | Correct | 30 ms | 824 KB | Output is correct |
55 | Correct | 4 ms | 824 KB | Output is correct |
56 | Correct | 3 ms | 824 KB | Output is correct |