# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61486 | 2018-07-26T05:24:31 Z | 김세빈(#1779) | Election (BOI18_election) | C++11 | 16 ms | 376 KB |
#include <bits/stdc++.h> using namespace std; char str[505050]; int L[505050], R[505050]; int n; int main() { int q, i, l, r, k, s; scanf("%d%s%d", &n, str, &q); for(; q--; ){ scanf("%d%d", &l, &r); k = s = 0; for(i=l; i<r; i++){ if(str[i-1] == 'C') s ++; else s --; L[i] = s; if(i > l) L[i] = min(L[i], L[i-1]); } s = 0; for(i=r; i>l; i--){ if(str[i-1] == 'C') s ++; else s --; R[i] = s; if(i < r) R[i] = min(R[i], R[i+1]); } for(i=l; i<r; i++){ k = max(k, max(0, -L[i]) + max(0, -R[i+1])); } printf("%d\n", k); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |