Submission #565600

#TimeUsernameProblemLanguageResultExecution timeMemory
565600DodoElection (BOI18_election)C++14
28 / 100
3063 ms1172 KiB
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define pb push_back using namespace std; int main() { ll n,q; string s; cin>>n>>s>>q; while(q--) { ll x,y; cin>>x>>y; x--; y--; ll arr[n]={}; ll t=0,c=0; for(int i=x;i<=y;i++) { if(s[i]=='C')c++; else t++; if(t>c) { arr[i]++; t--; } } t=0,c=0; for(int i=y;i>=x;i--) { if(s[i]=='C')c++; else if(arr[i]==0)t++; if(t>c) { arr[i]++; t--; } } ll ans=0; for(int i=0;i<n;i++) if(arr[i]>0)ans++; cout<<ans<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...