Submission #63523

#TimeUsernameProblemLanguageResultExecution timeMemory
63523mirbek01Election (BOI18_election)C++17
28 / 100
24 ms1088 KiB
# include <bits/stdc++.h> using namespace std; const int N = 2e3 + 2; int n, q, u[N]; string s; int main(){ cin >> n >> s >> q; s = ' ' + s; while(q --){ int l, r, ans = 0, a = 0, b = 0; cin >> l >> r; for(int i = l; i <= r; i ++){ if(s[i] == 'C') a ++; else b ++; if(b > a){ b --; u[i] = 1; ans ++; } } a = b = 0; for(int i = r; i >= l; i --){ if(s[i] == 'C') a ++; else if(!u[i]) b ++; if(b > a){ b --; ans ++; } u[i] = 0; } cout << ans << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...