# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
257938 |
2020-08-05T05:33:02 Z |
최은수(#5047) |
Toilets (JOI16_toilets) |
C++17 |
|
1 ms |
384 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(0ll,i-(n-mc+cc++)*2-1);
cout<<ans<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |