Submission #865253

#TimeUsernameProblemLanguageResultExecution timeMemory
865253faricaElection (BOI18_election)C++14
28 / 100
3065 ms1272 KiB
#include <bits/stdc++.h> #define long long ll using namespace std; const int MAX_N=1e6; void solve() { int n; cin >> n; string s; cin >> s; int q; cin >> q; while(q--) { int l,r; cin >> l >> r; --l; int cnt=0, ans=0; string tmp=s; for(int i=l; i<r; ++i) { if(s[i]=='C') ++cnt; else if(s[i]=='T') --cnt; if(cnt<0) { ++cnt; ++ans; tmp[i]='X'; } } cnt=0; for(int i=r-1; i>=l; --i) { if(tmp[i]=='C') ++cnt; else if(tmp[i]=='T') --cnt; if(cnt<0) { ++cnt; ++ans; } } cout << ans << endl; } } int main() { int T=1; while(T--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...