Submission #433811

#TimeUsernameProblemLanguageResultExecution timeMemory
433811AmineTrabelsiElection (BOI18_election)C++14
0 / 100
8 ms204 KiB
#include "bits/stdc++.h" using namespace std; // Hi int l,r; int main(){ ios::sync_with_stdio(0);cin.tie(0); int n; cin>>n; string s; cin>>s; int q; cin>>q; while(q--){ cin>>l>>r; l--,r--; vector<int> suff(n+1,0); for(int i=r;i>=l;i--){ suff[i] = suff[i+1]+(s[i] == 'C'); } int t = 0; int cnt_c = 0; int ans = 0; for(int i=l;i<=r;i++){ if(s[i] == 'T'){ if(t+1 <= cnt_c && t+1 <= suff[i]) t++; else ans++; }else { cnt_c++; if(t > 0)t--; } } cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...