# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
55422 |
2018-07-07T09:14:40 Z |
노영훈(#1544) |
Toilets (JOI16_toilets) |
C++11 |
|
5 ms |
3448 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;
ll n;
int m, K[MX];
string S[MX];
void NOPE(){
cout<<-1;
exit(0);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>m;
// ll sum=0, mn=0, ans=0;
if(m!=1) NOPE();
char S[MX]; int k;
for(int i=1; i<=m; i++){
cin>>(S+1)>>k;
int now=0, low=0, cnt=0, tmp=0;
for(int i=1; S[i]!=0; i++){
if(S[i]=='M'){
cnt++;
now++;
}
else{
now--;
}
if(low>now) low=now, tmp=cnt;
}
int need=max(0, -1-low);
if(need>cnt-tmp) NOPE();
else cout<<need;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |