Submission #55412

# Submission time Handle Problem Language Result Execution time Memory
55412 2018-07-07T08:26:47 Z 강태규(#1543) Toilets (JOI16_toilets) C++11
14 / 100
4 ms 876 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[100001];
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

toilets.cpp: In function 'int main()':
toilets.cpp:25:22: warning: format '%d' expects a matching 'int*' argument [-Wformat=]
     scanf("%s%d", str);
                      ^
toilets.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
toilets.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s%d", str);
     ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 520 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 2 ms 580 KB Output is correct
11 Correct 2 ms 580 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 2 ms 580 KB Output is correct
16 Correct 2 ms 580 KB Output is correct
17 Correct 2 ms 580 KB Output is correct
18 Correct 2 ms 580 KB Output is correct
19 Correct 2 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 2 ms 580 KB Output is correct
22 Correct 3 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 520 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 2 ms 580 KB Output is correct
11 Correct 2 ms 580 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 2 ms 580 KB Output is correct
16 Correct 2 ms 580 KB Output is correct
17 Correct 2 ms 580 KB Output is correct
18 Correct 2 ms 580 KB Output is correct
19 Correct 2 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 2 ms 580 KB Output is correct
22 Correct 3 ms 580 KB Output is correct
23 Runtime error 3 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 520 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 2 ms 580 KB Output is correct
11 Correct 2 ms 580 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 2 ms 580 KB Output is correct
16 Correct 2 ms 580 KB Output is correct
17 Correct 2 ms 580 KB Output is correct
18 Correct 2 ms 580 KB Output is correct
19 Correct 2 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 2 ms 580 KB Output is correct
22 Correct 3 ms 580 KB Output is correct
23 Runtime error 3 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Halted 0 ms 0 KB -