# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61465 | 2018-07-26T04:47:11 Z | 김세빈(#1779) | Election (BOI18_election) | C++11 | 5 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, a, b, k; scanf("%d%s%d", &n, str, &q); for(i=1; i<=n; i++){ if(str[i-1] == 'C') L[i] = L[i-1] - 1; else L[i] = L[i-1] + 1; } for(i=n; i>=1; i--){ if(str[i-1] == 'C') R[i] = R[i+1] - 1; else R[i] = R[i+1] + 1; } for(; q--; ){ scanf("%d%d", &l, &r); k = 0; for(i=l; i<=r; i++){ a = max(0, L[i] - L[l-1]); b = max(0, R[i] - R[r+1]); if(a && b) k = max(k, a + b - 1); else k = max(k, a + b); } printf("%d\n", k); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |