# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1089810 | lucri | Election (BOI18_election) | C++17 | 3063 ms | 1092 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>
using namespace std;
char a[500010];
bool e[500010];
int n,q,x,y;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>a+1>>q;
while(q--)
{
cin>>x>>y;
int sum=0;
for(int i=x;i<=y;++i)
{
if(a[i]=='C')
++sum;
else
--sum;
if(sum>=0)
e[i]=true;
else
{
e[i]=false;
++sum;
}
}
sum=0;
int ans=0;
for(int i=y;i>=x;--i)
{
if(e[i]==false)
{
++ans;
continue;
}
if(a[i]=='C')
++sum;
else
--sum;
if(sum>=0)
e[i]=true;
else
{
++ans;
e[i]=false;
++sum;
}
}
cout<<ans<<'\n';
}
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... |