QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#358322 | #407. Toilets | GoodKnight | 0 | 0ms | 3628kb | C++20 | 829b | 2024-03-19 19:05:24 | 2024-03-19 19:05:35 |
answer
#include<bits/stdc++.h>
using namespace std;
long long n, k;
long long mal=0;
long long femal=0;
string s;
void solve1(){
cin >> s;
cin >> k;
long long maxdif=0;
bool endsinf=0;
for(int i=0; i<2*n; i++){
if(s[i]=='M') mal++;
if(s[i]=='F') femal++;
if(femal-mal>maxdif&&i%2==1){
maxdif = femal-mal;
if(s[i]=='F') endsinf=1;
else endsinf=0;
}
if(femal-mal==maxdif&&i%2==1){
if(s[i]=='M') endsinf = 0;
}
}
if(femal<mal){
cout << "-1";
return;
}
long long wynik = maxdif-femal+mal;
if(wynik%2==0&&endsinf) wynik--;
cout << wynik;
return;
}
int main(){
cin >> n;
int m;
cin >> m;
if(m==1){
solve1();
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 14
Accepted
time: 0ms
memory: 3548kb
input:
10 1 FMFFFFFFMFFFMMMMMFMM 1
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
10 1 FFMFMMFFFFMMMFMMMMFF 1
output:
3
result:
ok single line: '3'
Test #3:
score: -14
Wrong Answer
time: 0ms
memory: 3584kb
input:
10 1 MFMMFFFMMFFMMMMFFFFF 1
output:
-1
result:
wrong answer 1st lines differ - expected: '0', found: '-1'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%