#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 (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;
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
0 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 |
256 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 |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
0 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 |
256 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 |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
0 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 |
256 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 |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |