Submission #433811

# Submission time Handle Problem Language Result Execution time Memory
433811 2021-06-20T11:01:35 Z AmineTrabelsi Election (BOI18_election) C++14
0 / 100
8 ms 204 KB
#include "bits/stdc++.h"
using namespace std;
// Hi 
int l,r;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q;
    cin>>q;
    while(q--){
        cin>>l>>r;
        l--,r--;
        vector<int> suff(n+1,0);
        for(int i=r;i>=l;i--){
            suff[i] = suff[i+1]+(s[i] == 'C');
        }
        int t = 0;
        int cnt_c = 0;
        int ans = 0;
        for(int i=l;i<=r;i++){
            if(s[i] == 'T'){
                if(t+1 <= cnt_c && t+1 <= suff[i])
                    t++;
                else ans++;
            }else {
                cnt_c++;
                if(t > 0)t--;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -