Submission #1203235

#TimeUsernameProblemLanguageResultExecution timeMemory
1203235JohanElection (BOI18_election)C++20
28 / 100
3095 ms1072 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; string s; cin >> n >> s >> q; s = '#' + s; while(q--){ int l, r; cin >> l >> r; string ss = s; int C = 0, T = 0, tot = 0; for(int i = l; i <= r; i++){ C += (s[i] == 'C'); T += (s[i] == 'T'); if(T > C) s[i] = '#', T--, tot++; } C = T = 0; for(int i = r; i >= l; i--){ C += (s[i] == 'C'); T += (s[i] == 'T'); if(T > C) s[i] = '#', T--, tot++; } cout << tot << endl; s = ss; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...