제출 #861389

#제출 시각아이디문제언어결과실행 시간메모리
861389maks007Election (BOI18_election)C++14
0 / 100
7 ms348 KiB
#include "bits/stdc++.h" using namespace std; signed main () { int n; cin >> n; string str; cin >> str; int q; cin >> q; while(q --) { int l, r; cin >> l >> r; l --, r --; int bal = 0, cnt1 = 0, cnt2 = 0; for(int i = l; i <= r; i ++) { if(str[i] == 'C') bal ++; else if(bal == 0) { cnt1 ++; }else bal --; } bal = 0; for(int i = r; i >= l; i --) { if(str[i] == 'C') bal ++; else if(bal == 0) { cnt2 ++; }else bal --; } cout << max(cnt1, cnt2) << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...