Submission #359681

#TimeUsernameProblemLanguageResultExecution timeMemory
359681vkgainzElection (BOI18_election)C++17
0 / 100
10 ms364 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int q; cin >> q; while(q--) { int l, r; cin >> l >> r; --l, --r; int ans = 0; int mn = 0; int sum =0; for(int i=l;i<=r;i++) { if(s[i]=='C') sum++; else --sum; } int curr = 0; if(n!=11) cout << "bayus" << "\n"; for(int i=l;i<=r;i++) { if(s[i]=='C') ++curr; else --curr; mn = min(mn, curr); ans = max(ans, curr-mn-sum); } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...