| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1311586 | dm2010 | Election (BOI18_election) | C++20 | 3094 ms | 732 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
string S;
cin >> S;
int Q;
cin >> Q;
while (Q--) {
int L, R;
cin >> L >> R;
L--; R--;
vector<bool> removed(R - L + 1, false);
int bal = 0;
for (int i = 0; i <= R - L; i++) {
if (removed[i]) continue;
if (S[L + i] == 'C') bal++;
else bal--;
if (bal < 0) {
removed[i] = true;
bal++;
}
}
bal = 0;
for (int i = R - L; i >= 0; i--) {
if (removed[i]) continue;
if (S[L + i] == 'C') bal++;
else bal--;
if (bal < 0) {
removed[i] = true;
bal++;
}
}
int ans = 0;
for (bool x : removed) ans += x;
cout << ans << "\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
