# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565649 | almothana05 | Election (BOI18_election) | C++14 | 3062 ms | 920 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define mod 1000000007
//////////////////////////////////////////////////////////
#define inf 100000000000000000
using namespace std;
int num[300000];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int menge , numm , nummer , que;
string s;
cin >> menge >> s;
cin >> que;
int erg;
while(que--){
erg = 0;
cin >> numm >> nummer;
numm--;
nummer--;
int t = 0 , c = 0;
for(int i = numm ; i <= nummer ; i++){
if(s[i] == 'T'){
t++;
}
else{
c++;
}
if(t > c){
num[i] = 1;
erg++;
t--;
}
}
t = 0;
c = 0;
for(int i = nummer; i >= numm ; i--){
if(num[i] == 1){
continue;
}
if(s[i] == 'T'){
t++;
}
else{
c++;
}
if(t > c){
num[i] = 1;
erg++;
t--;
}
}
cout << erg << "\n";
for(int i = 0 ; i < s.size() ; i++){
num[i] = 0;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |