Submission #570080

#TimeUsernameProblemLanguageResultExecution timeMemory
570080TsiannisElection (BOI18_election)C++17
0 / 100
9 ms340 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main () { ll n; cin>>n; string s; cin>>s; ll q; cin>>q; while(q--) { ll l,r; cin>>l>>r; l--;r--; ll cc=0; ll ct=0; ll ans1=0; for (int i=l;i<=r;i++) { if (s[i]=='C') cc++; else { if (ct==cc) { ans1++; } else { ct++; } } } ct=0; cc=0; ll ans2=0; for (int i=r;i>=l;i--) { if (s[i]=='C') cc++; else { if (ct==cc) { ans2++; } else { ct++; } } } cout<<max(ans1,ans2)<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...