# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
257946 |
2020-08-05T05:44:10 Z |
최은수(#5047) |
Toilets (JOI16_toilets) |
C++17 |
|
203 ms |
768 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin>>n;
int m;
cin>>m;
for(int tc=0;tc<m;tc++)
{
string s;
int k;
cin>>s>>k;
ll mc=0;
int sn=s.size();
for(int i=0;i<sn;i++)
if(s[i]=='M')
mc++;
if(mc>n)
return cout<<-1<<endl,0;
ll cc=0;
ll ans=0;
for(int i=0;i<sn;i++)
if(s[i]=='M')
ans=max(ans,i-(n-mc+cc++)*2-1);
cout<<ans<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
652 KB |
Output is correct |
24 |
Correct |
3 ms |
652 KB |
Output is correct |
25 |
Correct |
2 ms |
652 KB |
Output is correct |
26 |
Correct |
1 ms |
652 KB |
Output is correct |
27 |
Correct |
1 ms |
652 KB |
Output is correct |
28 |
Correct |
2 ms |
768 KB |
Output is correct |
29 |
Correct |
2 ms |
652 KB |
Output is correct |
30 |
Correct |
2 ms |
652 KB |
Output is correct |
31 |
Correct |
2 ms |
652 KB |
Output is correct |
32 |
Correct |
2 ms |
652 KB |
Output is correct |
33 |
Correct |
1 ms |
652 KB |
Output is correct |
34 |
Correct |
1 ms |
652 KB |
Output is correct |
35 |
Correct |
2 ms |
652 KB |
Output is correct |
36 |
Correct |
2 ms |
768 KB |
Output is correct |
37 |
Correct |
1 ms |
652 KB |
Output is correct |
38 |
Correct |
1 ms |
652 KB |
Output is correct |
39 |
Correct |
2 ms |
652 KB |
Output is correct |
40 |
Correct |
2 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
652 KB |
Output is correct |
24 |
Correct |
3 ms |
652 KB |
Output is correct |
25 |
Correct |
2 ms |
652 KB |
Output is correct |
26 |
Correct |
1 ms |
652 KB |
Output is correct |
27 |
Correct |
1 ms |
652 KB |
Output is correct |
28 |
Correct |
2 ms |
768 KB |
Output is correct |
29 |
Correct |
2 ms |
652 KB |
Output is correct |
30 |
Correct |
2 ms |
652 KB |
Output is correct |
31 |
Correct |
2 ms |
652 KB |
Output is correct |
32 |
Correct |
2 ms |
652 KB |
Output is correct |
33 |
Correct |
1 ms |
652 KB |
Output is correct |
34 |
Correct |
1 ms |
652 KB |
Output is correct |
35 |
Correct |
2 ms |
652 KB |
Output is correct |
36 |
Correct |
2 ms |
768 KB |
Output is correct |
37 |
Correct |
1 ms |
652 KB |
Output is correct |
38 |
Correct |
1 ms |
652 KB |
Output is correct |
39 |
Correct |
2 ms |
652 KB |
Output is correct |
40 |
Correct |
2 ms |
652 KB |
Output is correct |
41 |
Incorrect |
203 ms |
560 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |