# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565643 | Rifal | Election (BOI18_election) | C++14 | 3056 ms | 752 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>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
int main()
{
int n, q;
string ss;
cin >> n >> ss >> q;
while(q--)
{
int l, r;
cin >> l >> r;
long long sum = 0;
string s = ss;
long long tt = 0, cc = 0;
for(int i = l-1; i < r; i++)
{
if(s[i] == 'T')
{
if(cc > 0)
{
cc--;
}
else
{
s[i] = ' ';
sum++;
}
}
else if(s[i] != ' ')
{
cc++;
}
}
tt = 0, cc = 0;
for(int i = r-1; i >= l-1; i--)
{
if(s[i] == 'T')
{
if(cc > 0)
{
cc--;
}
else
{
s[i] = ' ';
sum++;
}
}
else if(s[i] != ' ')
{
cc++;
}
}
cout << sum << endl;
}
return 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... |