Submission #157030

# Submission time Handle Problem Language Result Execution time Memory
157030 2019-10-09T07:55:56 Z jhwest2 Toilets (JOI16_toilets) C++14
0 / 100
3 ms 504 KB
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N, M, K, cnt;
string s;
vector<int> A, B;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);

	cin >> N >> M;
	cin >> s >> K;

	for (int i=0; i<s.size(); i++) {
		if (s[i] == 'F') ++cnt;
		else A.push_back(cnt);
	}

	if (A.size() > N) { cout << -1; return 0; }
	for (int i=0; i<A.size(); i++) {
		B.push_back(min(A[i], 2*(N-(int)A.size())+1+i));
	}

	int ans=0, ap=0, bp=0;
	for (int i=1; i<=N; i++) {
		while (A[ap]<i && ap!=A.size()) ++ap;
		while (B[bp]<i && bp!=B.size()) ++bp;
		ans = max(ans, bp-ap);
	}

	cout << ans;
}

Compilation message

toilets.cpp: In function 'int main()':
toilets.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<s.size(); i++) {
                ~^~~~~~~~~
toilets.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (A.size() > N) { cout << -1; return 0; }
      ~~~~~~~~~^~~
toilets.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<A.size(); i++) {
                ~^~~~~~~~~
toilets.cpp:30:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (A[ap]<i && ap!=A.size()) ++ap;
                     ~~^~~~~~~~~~
toilets.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (B[bp]<i && bp!=B.size()) ++bp;
                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Halted 0 ms 0 KB -