Submission #257914

# Submission time Handle Problem Language Result Execution time Memory
257914 2020-08-05T04:42:29 Z 반딧불(#5055) Toilets (JOI16_toilets) C++17
36 / 100
14 ms 2184 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n, k;
string s;
vector<int> m, f;
int ans;
int depth;

int main(){
    cin >> n >> k >> s;
    for(int i=0; i<n+n; i++){
        if(s[i] == 'M') m.push_back(i);
        else f.push_back(i);
    }
    if((int)m.size() > n){
        printf("-1");
        return 0;
    }

    reverse(s.begin(), s.end());
    for(int i=0; i<n+n; i++){
        if(s[i] == 'M') depth--;
        else depth++;
        ans = max(ans, -depth-1);
    }
    printf("%d", ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 14 ms 1800 KB Output is correct
24 Correct 14 ms 1800 KB Output is correct
25 Correct 13 ms 1928 KB Output is correct
26 Correct 12 ms 1928 KB Output is correct
27 Correct 12 ms 1928 KB Output is correct
28 Correct 13 ms 1800 KB Output is correct
29 Correct 14 ms 2180 KB Output is correct
30 Correct 13 ms 1872 KB Output is correct
31 Correct 14 ms 1668 KB Output is correct
32 Correct 14 ms 1668 KB Output is correct
33 Correct 12 ms 1928 KB Output is correct
34 Correct 13 ms 1836 KB Output is correct
35 Correct 14 ms 1632 KB Output is correct
36 Correct 14 ms 1676 KB Output is correct
37 Correct 12 ms 1928 KB Output is correct
38 Correct 12 ms 1716 KB Output is correct
39 Correct 13 ms 1632 KB Output is correct
40 Correct 13 ms 2184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 14 ms 1800 KB Output is correct
24 Correct 14 ms 1800 KB Output is correct
25 Correct 13 ms 1928 KB Output is correct
26 Correct 12 ms 1928 KB Output is correct
27 Correct 12 ms 1928 KB Output is correct
28 Correct 13 ms 1800 KB Output is correct
29 Correct 14 ms 2180 KB Output is correct
30 Correct 13 ms 1872 KB Output is correct
31 Correct 14 ms 1668 KB Output is correct
32 Correct 14 ms 1668 KB Output is correct
33 Correct 12 ms 1928 KB Output is correct
34 Correct 13 ms 1836 KB Output is correct
35 Correct 14 ms 1632 KB Output is correct
36 Correct 14 ms 1676 KB Output is correct
37 Correct 12 ms 1928 KB Output is correct
38 Correct 12 ms 1716 KB Output is correct
39 Correct 13 ms 1632 KB Output is correct
40 Correct 13 ms 2184 KB Output is correct
41 Runtime error 1 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -