# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
793107 | 2023-07-25T13:59:12 Z | pasin30055 | Election (BOI18_election) | C++14 | 6 ms | 724 KB |
#include <cstdio> #include <cstdlib> #include <iostream> #define MAXN 2005 using namespace std; int n, q, l, r; int a[MAXN], b[MAXN], c[MAXN], d[MAXN]; char s[MAXN]; int main() { scanf("%d\n%s\n%d", &n, s, &q); for (; q > 0; q --) { scanf("%d %d", &l, &r); a[l - 1] = 0; b[r + 1] = 0; c[l - 1] = 0; d[r + 1] = 0; int ans = 0; for (int i = l ; i <= r ; i ++) { a[i] = a[i - 1]; if (s[i - 1] == 'C') a[i]--; else a[i]++; c[i] = max(c[i - 1], a[i]); } for (int i = r ; i >= l; i --) { b[i] = b[i + 1]; if (s[i - 1] == 'C') b[i]--; else b[i]++; d[i] = max(d[i + 1], b[i]); ans = max(ans, d[i + 1] + c[i]); } printf("%d\n", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 320 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 5 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 320 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 5 ms | 340 KB | Output is correct |
6 | Runtime error | 1 ms | 724 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 320 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 5 ms | 340 KB | Output is correct |
6 | Runtime error | 1 ms | 724 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |