# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1018716 | phoenix | Election (BOI18_election) | C++17 | 3089 ms | 1336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
s = '#' + s;
int q;
cin >> q;
bool us[n + 1] = {};
while (q--) {
int l, r;
cin >> l >> r;
int suf = 0, cur = 0;
for (int i = l; i <= r; i++) {
suf += (s[i] == 'C');
}
int k = 0, cnt = 0;
for (int i = l; i <= r; i++) {
if (s[i] == 'C') {
cur++;
if (k) k--;
else suf--;
cnt++;
} else {
if (cur && suf) {
cur--;
suf--;
k++;
cnt++;
}
}
}
cout << r - l + 1 - cnt << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |