Submission #849298

#TimeUsernameProblemLanguageResultExecution timeMemory
849298JoksimKaktusElection (BOI18_election)C++17
0 / 100
6 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int n,q; string s; cin >> n >> s >> q; for(int i = 0;i < q;i++){ int l,r; cin >> l >> r; vector <bool> vis(n,false); int c = 0; int t = 0; for(int j = l-1; j < r;j++){ if(s.at(j) == 'C'){ c++; }else{ t++; if(t > c){ t--; vis[j] = true; } } } c = 0; t = 0; for(int j = r-1; j > l;j--){ if(s.at(j) == 'C'){ c++; }else if(!vis[j]){ t++; if(t > c){ t--; vis[j] = true; } } } int res = 0; for(int j = l-1;j < r;j++){ if(vis[j]){ res++; } } cout << res << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...