QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#358510 | #407. Toilets | robsob2006 | 0 | 1ms | 3696kb | C++14 | 1.1kb | 2024-03-19 20:26:49 | 2024-03-19 20:26:49 |
answer
#include <bits/stdc++.h>
using namespace std;
char tab[400007];
queue <int> kicked;
int vis[400007];
int main()
{
int n, m, k, i, j, a, b, men=0, s, inst=0, ok;
cin >> n;
cin >> m;
for(i=0; i<m; i++){
cin >> tab >> k;
for(j=0; j<strlen(tab); j++){
if(tab[j]=='M'){
men+=k;
}
}
}
if(men>n){
cout << "-1\n";
return 0;
}
a=0;
b=1;
while(a<2*n){
if((tab[a]=='M')&&(tab[b]=='M')){
while((tab[b]=='M')||(vis[b]==1)){
b++;
if(b==2*n){
inst++;
break;
}
}
}
//cout << a << ' ' << b << '\n';
vis[a]=1;
vis[b]=1;
while(vis[a]==1){
a++;
if(a>2*n){
break;
}
}
b=a+1;
while(vis[b]==1){
b++;
if(b>=2*n){
inst++;
break;
}
}
}
cout << inst << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3696kb
input:
10 1 FMFFFFFFMFFFMMMMMFMM 1
output:
6
result:
wrong answer 1st lines differ - expected: '5', found: '6'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%