Submission #611111

# Submission time Handle Problem Language Result Execution time Memory
611111 2022-07-29T03:08:28 Z talant117408 Election (BOI18_election) C++17
0 / 100
3 ms 340 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define long                unsigned long 
#define pb                  push_back
#define mp                  make_pair
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define lb                  lower_bound
#define ub                  upper_bound
#define sz(v)               int((v).size())
#define do_not_disturb      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl                '\n'
#define PI                  2*acos(0.0)

void solve(int test) {
    int n;
    cin >> n;
    string votes;
    cin >> votes;
    votes = '1' + votes;
    int q;
    cin >> q;
    if (n <= 2000 && q <= 2000) {
        while (q--) {
            int l, r;
            cin >> l >> r;
            int balance = 0;
            vector <int> used(n + 1);
            int mx = -2e9;
            for (int i = l; i <= r; i++) {
                balance += (votes[i] == 'C' ? 1 : -1);
                mx = max(mx, -balance);
                
            }
            balance = 0;
            for (int i = r; i >= l; i--) {
                balance += (votes[i] == 'C' ? 1 : -1);
                mx = max(mx, -balance);
            }
            cout << max(0, mx) << endl;
        }
    }
}  

int main() {
    do_not_disturb
    
    int t = 1;
    //~ cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -