# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105888 | 2019-04-15T14:32:47 Z | IOrtroiii | Election (BOI18_election) | C++14 | 3000 ms | 1688 KB |
#include <bits/stdc++.h> using namespace std; const int N = 500500; char s[N]; bool del[N]; int brute(int l,int r) { int nw = 0; int ans = 0; for (int i = l; i <= r; ++i) { nw += (s[i] == 'C' ? +1 : -1); if (nw < 0) { ++ans; del[i] = true; nw = 0; } } nw = 0; for (int i = r; i >= l; --i) { if (del[i]) continue; nw += (s[i] == 'C' ? +1 : -1); if (nw < 0) { ++ans; del[i] = true; nw = 0; } } for (int i = l; i <= r; ++i) del[i] = false; return ans; } int main() { int n; scanf("%d %s", &n, s + 1); int q; scanf("%d", &q); for (int i = 1; i <= q; ++i) { int l, r; scanf("%d %d", &l, &r); printf("%d\n", brute(l, r)); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 396 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 404 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 396 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 404 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 304 KB | Output is correct |
6 | Execution timed out | 3100 ms | 1688 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 396 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 404 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 304 KB | Output is correct |
6 | Execution timed out | 3100 ms | 1688 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |