Submission #1085066

#TimeUsernameProblemLanguageResultExecution timeMemory
1085066elotelo966Election (BOI18_election)C++17
0 / 100
7 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define OYY LLONG_MAX #define mod 998244353 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define FOR for(int i=1;i<=n;i++) #define mid (start+end)/2 #define lim 10005 #define fi first #define se second int32_t main(){ faster int n;cin>>n; string s;cin>>s; int q;cin>>q; while(q--){ vector<int> v(n,0); int top=0; int l,r;cin>>l>>r; l--;r--; for(int i=l;i<r;i++){ if(s[i]=='C')top++; else{ top--; if(top<0)v[i]=1; } } top=0; for(int i=r;i>=l;i--){ //cout<<top<<endl; if(s[i]=='C')top++; else if(v[i]==1)continue; else{ top--; if(top<0)v[i]=1; } } top=0; for(int i=l;i<=r;i++){ top+=v[i]; //cout<<v[i]<<endl; } cout<<top<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...