제출 #237600

#제출 시각아이디문제언어결과실행 시간메모리
237600SortingElection (BOI18_election)C++14
0 / 100
8 ms384 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){ if(r) r--; else sum++; } else if(a[i] == -1){ if(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...