답안 #157032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157032 2019-10-09T07:59:11 Z jhwest2 Toilets (JOI16_toilets) C++14
36 / 100
17 ms 2044 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<=2*N; i++) {
		while (ap!=A.size() && A[ap]<i) ++ap;
		while (bp!=B.size() && B[bp]<i) ++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:25:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<A.size(); i++) {
                ~^~~~~~~~~
toilets.cpp:31:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (ap!=A.size() && A[ap]<i) ++ap;
          ~~^~~~~~~~~~
toilets.cpp:32:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (bp!=B.size() && B[bp]<i) ++bp;
          ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 7 ms 1916 KB Output is correct
24 Correct 7 ms 2044 KB Output is correct
25 Correct 7 ms 1788 KB Output is correct
26 Correct 4 ms 900 KB Output is correct
27 Correct 5 ms 1916 KB Output is correct
28 Correct 7 ms 1788 KB Output is correct
29 Correct 6 ms 1788 KB Output is correct
30 Correct 7 ms 1916 KB Output is correct
31 Correct 7 ms 1916 KB Output is correct
32 Correct 7 ms 1916 KB Output is correct
33 Correct 5 ms 1916 KB Output is correct
34 Correct 4 ms 1028 KB Output is correct
35 Correct 8 ms 1916 KB Output is correct
36 Correct 17 ms 1916 KB Output is correct
37 Correct 4 ms 900 KB Output is correct
38 Correct 5 ms 1408 KB Output is correct
39 Correct 6 ms 1788 KB Output is correct
40 Correct 6 ms 1788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 7 ms 1916 KB Output is correct
24 Correct 7 ms 2044 KB Output is correct
25 Correct 7 ms 1788 KB Output is correct
26 Correct 4 ms 900 KB Output is correct
27 Correct 5 ms 1916 KB Output is correct
28 Correct 7 ms 1788 KB Output is correct
29 Correct 6 ms 1788 KB Output is correct
30 Correct 7 ms 1916 KB Output is correct
31 Correct 7 ms 1916 KB Output is correct
32 Correct 7 ms 1916 KB Output is correct
33 Correct 5 ms 1916 KB Output is correct
34 Correct 4 ms 1028 KB Output is correct
35 Correct 8 ms 1916 KB Output is correct
36 Correct 17 ms 1916 KB Output is correct
37 Correct 4 ms 900 KB Output is correct
38 Correct 5 ms 1408 KB Output is correct
39 Correct 6 ms 1788 KB Output is correct
40 Correct 6 ms 1788 KB Output is correct
41 Incorrect 2 ms 376 KB Output isn't correct
42 Halted 0 ms 0 KB -