Submission #1082400

# Submission time Handle Problem Language Result Execution time Memory
1082400 2024-08-31T09:43:43 Z SulA Election (BOI18_election) C++17
0 / 100
4 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

int solve(string s) {
    int pref = 0, min_pref = 0;
    for (char c : s) {
        pref += (c == 'C' ? 1 : -1);
        min_pref = min(pref, min_pref);
    }
    int suff = 0, min_suff = 0;
    reverse(s.begin(), s.end());
    for (char c : s) {
        suff += (c == 'C' ? 1 : -1);
        min_suff = min(suff, min_suff);
    }
    return max(-min_pref, -min_suff);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q; while (q--) {
        int l,r; cin >> l >> r;
        l--, r--;
        cout << solve(s.substr(l, r-l+1)) << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -