Submission #257970

# Submission time Handle Problem Language Result Execution time Memory
257970 2020-08-05T06:39:08 Z 임성재(#5053) Toilets (JOI16_toilets) C++17
36 / 100
8 ms 6784 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

ll n, m;
string s[100010];
int k[100010];
int F[200010], M[200010];

int main() {
	fast;

	cin >> n;
	cin >> m;

	n *= 2;

	for(int i=1; i<=m; i++) {
		cin >> s[i] >> k[i];
	}

	for(int i=0; i<s[1].size(); i++) {
		F[i+1] = F[i];
		M[i+1] = M[i];

		if(s[1][i] == 'F') F[i+1]++;
		else M[i+1]++;
	}

	if(F[n] < M[n]) {
		cout << -1;
		return 0;
	}

	int ans = 0;
	for(int i=0; i<s[1].size(); i++) {
		if(s[1][i] == 'F') 
			ans = max(ans, (M[n] - M[i]) - (F[n] - F[i]));
	}

	cout << ans;
}

Compilation message

toilets.cpp: In function 'int main()':
toilets.cpp:37:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s[1].size(); i++) {
               ~^~~~~~~~~~~~
toilets.cpp:51:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s[1].size(); i++) {
               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3456 KB Output is correct
2 Correct 2 ms 3456 KB Output is correct
3 Correct 3 ms 3456 KB Output is correct
4 Correct 2 ms 3456 KB Output is correct
5 Correct 2 ms 3456 KB Output is correct
6 Correct 2 ms 3456 KB Output is correct
7 Correct 2 ms 3456 KB Output is correct
8 Correct 2 ms 3456 KB Output is correct
9 Correct 2 ms 3456 KB Output is correct
10 Correct 2 ms 3456 KB Output is correct
11 Correct 2 ms 3456 KB Output is correct
12 Correct 2 ms 3456 KB Output is correct
13 Correct 2 ms 3456 KB Output is correct
14 Correct 2 ms 3456 KB Output is correct
15 Correct 2 ms 3456 KB Output is correct
16 Correct 2 ms 3456 KB Output is correct
17 Correct 3 ms 3584 KB Output is correct
18 Correct 2 ms 3456 KB Output is correct
19 Correct 2 ms 3456 KB Output is correct
20 Correct 2 ms 3456 KB Output is correct
21 Correct 3 ms 3456 KB Output is correct
22 Correct 3 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3456 KB Output is correct
2 Correct 2 ms 3456 KB Output is correct
3 Correct 3 ms 3456 KB Output is correct
4 Correct 2 ms 3456 KB Output is correct
5 Correct 2 ms 3456 KB Output is correct
6 Correct 2 ms 3456 KB Output is correct
7 Correct 2 ms 3456 KB Output is correct
8 Correct 2 ms 3456 KB Output is correct
9 Correct 2 ms 3456 KB Output is correct
10 Correct 2 ms 3456 KB Output is correct
11 Correct 2 ms 3456 KB Output is correct
12 Correct 2 ms 3456 KB Output is correct
13 Correct 2 ms 3456 KB Output is correct
14 Correct 2 ms 3456 KB Output is correct
15 Correct 2 ms 3456 KB Output is correct
16 Correct 2 ms 3456 KB Output is correct
17 Correct 3 ms 3584 KB Output is correct
18 Correct 2 ms 3456 KB Output is correct
19 Correct 2 ms 3456 KB Output is correct
20 Correct 2 ms 3456 KB Output is correct
21 Correct 3 ms 3456 KB Output is correct
22 Correct 3 ms 3456 KB Output is correct
23 Correct 5 ms 5388 KB Output is correct
24 Correct 6 ms 5388 KB Output is correct
25 Correct 5 ms 5388 KB Output is correct
26 Correct 5 ms 5388 KB Output is correct
27 Correct 5 ms 5388 KB Output is correct
28 Correct 6 ms 5388 KB Output is correct
29 Correct 5 ms 5388 KB Output is correct
30 Correct 5 ms 5388 KB Output is correct
31 Correct 6 ms 5388 KB Output is correct
32 Correct 5 ms 5388 KB Output is correct
33 Correct 4 ms 5388 KB Output is correct
34 Correct 4 ms 5388 KB Output is correct
35 Correct 7 ms 5388 KB Output is correct
36 Correct 7 ms 5388 KB Output is correct
37 Correct 5 ms 5388 KB Output is correct
38 Correct 6 ms 5388 KB Output is correct
39 Correct 5 ms 5388 KB Output is correct
40 Correct 5 ms 5388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3456 KB Output is correct
2 Correct 2 ms 3456 KB Output is correct
3 Correct 3 ms 3456 KB Output is correct
4 Correct 2 ms 3456 KB Output is correct
5 Correct 2 ms 3456 KB Output is correct
6 Correct 2 ms 3456 KB Output is correct
7 Correct 2 ms 3456 KB Output is correct
8 Correct 2 ms 3456 KB Output is correct
9 Correct 2 ms 3456 KB Output is correct
10 Correct 2 ms 3456 KB Output is correct
11 Correct 2 ms 3456 KB Output is correct
12 Correct 2 ms 3456 KB Output is correct
13 Correct 2 ms 3456 KB Output is correct
14 Correct 2 ms 3456 KB Output is correct
15 Correct 2 ms 3456 KB Output is correct
16 Correct 2 ms 3456 KB Output is correct
17 Correct 3 ms 3584 KB Output is correct
18 Correct 2 ms 3456 KB Output is correct
19 Correct 2 ms 3456 KB Output is correct
20 Correct 2 ms 3456 KB Output is correct
21 Correct 3 ms 3456 KB Output is correct
22 Correct 3 ms 3456 KB Output is correct
23 Correct 5 ms 5388 KB Output is correct
24 Correct 6 ms 5388 KB Output is correct
25 Correct 5 ms 5388 KB Output is correct
26 Correct 5 ms 5388 KB Output is correct
27 Correct 5 ms 5388 KB Output is correct
28 Correct 6 ms 5388 KB Output is correct
29 Correct 5 ms 5388 KB Output is correct
30 Correct 5 ms 5388 KB Output is correct
31 Correct 6 ms 5388 KB Output is correct
32 Correct 5 ms 5388 KB Output is correct
33 Correct 4 ms 5388 KB Output is correct
34 Correct 4 ms 5388 KB Output is correct
35 Correct 7 ms 5388 KB Output is correct
36 Correct 7 ms 5388 KB Output is correct
37 Correct 5 ms 5388 KB Output is correct
38 Correct 6 ms 5388 KB Output is correct
39 Correct 5 ms 5388 KB Output is correct
40 Correct 5 ms 5388 KB Output is correct
41 Runtime error 8 ms 6784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -