제출 #1026773

#제출 시각아이디문제언어결과실행 시간메모리
1026773vjudge1Election (BOI18_election)C++17
28 / 100
3046 ms2084 KiB
#include <bits/stdc++.h> using namespace std; int n, q; string votes; unordered_map<int, bool> nulified; int main() { cin>>n>>votes>>q; for(int i = 0; i < q; i++) { int l, r; cin>>l>>r; l--; r--; int cap = 0, tony = 0, res = 0; nulified.clear(); for(int i = l; i <= r; i++) { if(votes[i] == 'C') cap++; else tony++; if(cap < tony) { res++; tony--; nulified[i] = true; } } cap = 0; tony = 0; for(int i = r; i >= l; i--) { if(votes[i] == 'C') cap++; else if(!nulified[i]) tony++; if(cap < tony) { res++; tony--; } } cout<<res<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...