# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433797 | 2021-06-20T10:56:00 Z | AmineTrabelsi | Election (BOI18_election) | C++14 | 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 c = 0; int ans = 0; for(int i=l;i<=r;i++){ if(s[i] == 'T'){ if(t+1 <= suff[i])t++; else ans++; }else { if(t > 0)t--; } } cout << ans << '\n'; } return 0; }
Compilation message
# | 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 | - |