Submission #237601

#TimeUsernameProblemLanguageResultExecution timeMemory
237601SortingElection (BOI18_election)C++14
28 / 100
3086 ms1912 KiB
#include <bits/stdc++.h> using namespace std; const int mx_N = 5e5 + 3; int n, q; string s; int a[mx_N]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> s; for(int i = 0; i < n; ++i) a[i + 1] = (s[i] == 'C') ? 1 : -1; cin >> q; for(int i = 0; i < q; ++i){ int lq, rq; cin >> lq >> rq; int sum = 0, l = 0, r = 0; for(int i = lq; i <= rq; ++i){ if(a[i] == 1){ r -= (bool)r; sum++; } else if(a[i] == -1){ if(sum){ sum--; r++; } else l++; } } cout << l + r << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...