QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#358729 | #407. Toilets | stevo | 14 | 1ms | 3816kb | C++20 | 530b | 2024-03-19 23:13:29 | 2024-03-19 23:13:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int N = 1e5+3;
int pref[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n;
int m, x, out=0;
cin >> n >> m;
string s;
cin >> s >> x;
x=0;
for(int i=2*n-1; i>=0; i--){
pref[i]=pref[i+1];
if(s[i]=='M'){
pref[i]--;
x++;
}else pref[i]++;
out=min(out, pref[i]);
}
if(x>n){
cout << -1 << '\n';
return 0;
}
out*=(-1);
out--;
cout << max(0, out) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 14
Accepted
Test #1:
score: 14
Accepted
time: 1ms
memory: 3768kb
input:
10 1 FMFFFFFFMFFFMMMMMFMM 1
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
10 1 FFMFMMFFFFMMMFMMMMFF 1
output:
3
result:
ok single line: '3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
10 1 MFMMFFFMMFFMMMMFFFFF 1
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
10 1 FMFMFFMFMFMMFFMFMFMM 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
10 1 MFFFMFMMMMMMMMMFMFFM 1
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
10 1 FFFFFFFMMFMFMMMMFFMF 1
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
10 1 FMFFFFFMMMFFFMMMFMMF 1
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
10 1 MFFMMMMMFFFFMMFFMMFF 1
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
10 1 MMMMMMFMFMMMFFMFMFMM 1
output:
-1
result:
ok single line: '-1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
10 1 FFFFFFFFFFFFFFFFFFFF 1
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
10 1 MMMMMMMMMMMMMMMMMMMM 1
output:
-1
result:
ok single line: '-1'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
10 1 FFFFFFFFFFFFFFFMMMMM 1
output:
4
result:
ok single line: '4'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10 1 FFFFFFFFFFMMMMMMMMMM 1
output:
9
result:
ok single line: '9'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
10 1 FMFMFMMFFFMFFMMMFMMF 1
output:
2
result:
ok single line: '2'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
10 1 FFFFFFFFFFFFFMMFMMMF 1
output:
2
result:
ok single line: '2'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
10 1 MMMMFMFFMFMFFFFMMFFM 1
output:
0
result:
ok single line: '0'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
10 1 MFMMFFFMMMMFFMMFFFMF 1
output:
0
result:
ok single line: '0'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
10 1 MFFFFMFMFFMMFMMFMFFM 1
output:
1
result:
ok single line: '1'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
10 1 MFFFFFFFFFFFFMFFFFFF 1
output:
0
result:
ok single line: '0'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
10 1 FFFMFFMFMMFFMMMMMFMF 1
output:
3
result:
ok single line: '3'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
10 1 MMFMFFFMFMMMFFMFMFFM 1
output:
0
result:
ok single line: '0'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
10 1 FFFFFFFFFFFMFFFFMFMM 1
output:
1
result:
ok single line: '1'
Subtask #2:
score: 0
Runtime Error
Dependency #1:
100%
Accepted
Test #23:
score: 0
Runtime Error
input:
100000 1 FFFFMMMFMFFMMMFFMFFFMFFFFFMMFFMMFMFFMFFFFMFFMMFFFFFFFFMFFMFMFMFFMFMFFFFFFMFMMFMMFMFFFFFFFFFMFMFFMFFMMFMFFFMFMFFFFFFMFMFFFFMFFMFMFMFFFMFFMFFFFFMMMFFMMFFFFFFFFFFFFMFFFFMFFFFFMMMFMFFFMMFFFMFMFFMMFFFFFMFFMFFFMFFFMFFMFFMFFFMFFMMFFFFFFFMFFFFFFFFFMFFFFFFFFFFFFFFFMMFFFFFMMMMFFFFMFMMFFMFFFFFMMMMFFFF...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%