# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55428 | 2018-07-07T09:27:05 Z | 내가진짜뚜룹뚭스(#2073) | Toilets (JOI16_toilets) | C++11 | 43 ms | 3808 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct seg { ll mini, sum, cnt; seg(){} seg(ll m, ll s, ll c):mini(m),sum(s),cnt(c){} }; ll n, m, INF = 1LL<<60; vector<seg> vec; char str[200100]; int main() { scanf("%lld%lld",&n,&m); int i, j; ll ap = 0, ans = INF; for (i=0;i<m;i++) { ll k; scanf(" %s%d",str,&k); ll p = 0, mini = INF; int len = strlen(str); for (j=0;j<len;j++) { p+=(str[j]=='M'?1:-1); if (str[j]=='F') { mini = min(mini,p); } } ans = min(ans,min(ap+mini,ap+p*(k-1)+mini)); ap += p*k; vec.push_back(seg(mini,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 | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 476 KB | Output is correct |
3 | Correct | 3 ms | 476 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 3 ms | 516 KB | Output is correct |
7 | Correct | 2 ms | 516 KB | Output is correct |
8 | Correct | 3 ms | 516 KB | Output is correct |
9 | Correct | 2 ms | 516 KB | Output is correct |
10 | Correct | 3 ms | 516 KB | Output is correct |
11 | Correct | 3 ms | 516 KB | Output is correct |
12 | Correct | 2 ms | 516 KB | Output is correct |
13 | Correct | 2 ms | 516 KB | Output is correct |
14 | Correct | 3 ms | 516 KB | Output is correct |
15 | Correct | 3 ms | 516 KB | Output is correct |
16 | Correct | 2 ms | 516 KB | Output is correct |
17 | Correct | 2 ms | 516 KB | Output is correct |
18 | Correct | 3 ms | 516 KB | Output is correct |
19 | Correct | 2 ms | 516 KB | Output is correct |
20 | Correct | 3 ms | 516 KB | Output is correct |
21 | Correct | 2 ms | 516 KB | Output is correct |
22 | Correct | 3 ms | 516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 476 KB | Output is correct |
3 | Correct | 3 ms | 476 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 3 ms | 516 KB | Output is correct |
7 | Correct | 2 ms | 516 KB | Output is correct |
8 | Correct | 3 ms | 516 KB | Output is correct |
9 | Correct | 2 ms | 516 KB | Output is correct |
10 | Correct | 3 ms | 516 KB | Output is correct |
11 | Correct | 3 ms | 516 KB | Output is correct |
12 | Correct | 2 ms | 516 KB | Output is correct |
13 | Correct | 2 ms | 516 KB | Output is correct |
14 | Correct | 3 ms | 516 KB | Output is correct |
15 | Correct | 3 ms | 516 KB | Output is correct |
16 | Correct | 2 ms | 516 KB | Output is correct |
17 | Correct | 2 ms | 516 KB | Output is correct |
18 | Correct | 3 ms | 516 KB | Output is correct |
19 | Correct | 2 ms | 516 KB | Output is correct |
20 | Correct | 3 ms | 516 KB | Output is correct |
21 | Correct | 2 ms | 516 KB | Output is correct |
22 | Correct | 3 ms | 516 KB | Output is correct |
23 | Correct | 4 ms | 696 KB | Output is correct |
24 | Correct | 4 ms | 696 KB | Output is correct |
25 | Correct | 5 ms | 824 KB | Output is correct |
26 | Correct | 3 ms | 824 KB | Output is correct |
27 | Correct | 4 ms | 824 KB | Output is correct |
28 | Correct | 5 ms | 824 KB | Output is correct |
29 | Correct | 5 ms | 824 KB | Output is correct |
30 | Correct | 4 ms | 824 KB | Output is correct |
31 | Correct | 6 ms | 824 KB | Output is correct |
32 | Correct | 4 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 | 5 ms | 824 KB | Output is correct |
36 | Correct | 4 ms | 824 KB | Output is correct |
37 | Correct | 4 ms | 824 KB | Output is correct |
38 | Correct | 5 ms | 824 KB | Output is correct |
39 | Correct | 5 ms | 824 KB | Output is correct |
40 | Correct | 4 ms | 824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 476 KB | Output is correct |
3 | Correct | 3 ms | 476 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 3 ms | 516 KB | Output is correct |
7 | Correct | 2 ms | 516 KB | Output is correct |
8 | Correct | 3 ms | 516 KB | Output is correct |
9 | Correct | 2 ms | 516 KB | Output is correct |
10 | Correct | 3 ms | 516 KB | Output is correct |
11 | Correct | 3 ms | 516 KB | Output is correct |
12 | Correct | 2 ms | 516 KB | Output is correct |
13 | Correct | 2 ms | 516 KB | Output is correct |
14 | Correct | 3 ms | 516 KB | Output is correct |
15 | Correct | 3 ms | 516 KB | Output is correct |
16 | Correct | 2 ms | 516 KB | Output is correct |
17 | Correct | 2 ms | 516 KB | Output is correct |
18 | Correct | 3 ms | 516 KB | Output is correct |
19 | Correct | 2 ms | 516 KB | Output is correct |
20 | Correct | 3 ms | 516 KB | Output is correct |
21 | Correct | 2 ms | 516 KB | Output is correct |
22 | Correct | 3 ms | 516 KB | Output is correct |
23 | Correct | 4 ms | 696 KB | Output is correct |
24 | Correct | 4 ms | 696 KB | Output is correct |
25 | Correct | 5 ms | 824 KB | Output is correct |
26 | Correct | 3 ms | 824 KB | Output is correct |
27 | Correct | 4 ms | 824 KB | Output is correct |
28 | Correct | 5 ms | 824 KB | Output is correct |
29 | Correct | 5 ms | 824 KB | Output is correct |
30 | Correct | 4 ms | 824 KB | Output is correct |
31 | Correct | 6 ms | 824 KB | Output is correct |
32 | Correct | 4 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 | 5 ms | 824 KB | Output is correct |
36 | Correct | 4 ms | 824 KB | Output is correct |
37 | Correct | 4 ms | 824 KB | Output is correct |
38 | Correct | 5 ms | 824 KB | Output is correct |
39 | Correct | 5 ms | 824 KB | Output is correct |
40 | Correct | 4 ms | 824 KB | Output is correct |
41 | Correct | 43 ms | 3804 KB | Output is correct |
42 | Incorrect | 35 ms | 3808 KB | Output isn't correct |
43 | Halted | 0 ms | 0 KB | - |