# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69509 | 2018-08-21T06:52:38 Z | 3zp | Election (BOI18_election) | C++14 | 13 ms | 248 KB |
#include<bits/stdc++.h> using namespace std; main(){ int n; cin >> n; string s; cin >> s; int q; cin >> q; while(q--){ int l, r; cin >> l >> r; l --; r --; int S = 0, Ma = 0, Mi = 0, Mai = l, Mii = l; for(int i = l; i <= r; i++){ if(s[i] == 'C') S++; else S--; if(S < Mi){ Mi = S; Mii = i; } if(S >= Ma){ Ma = S; Mai = i; } } int D1 = abs(S - Ma); int D2 = abs(Mi); if(Mii > Mai) cout << max(D1,D2) << endl; else cout << D1+D2 << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |