# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69515 | 2018-08-21T07:04:40 Z | 3zp | Election (BOI18_election) | C++14 | 3000 ms | 3204 KB |
#include<bits/stdc++.h> using namespace std; int s[500009]; main(){ int n; cin >> n; string W; cin >> W; for(int i = 1; i <= W.size(); i++) if(W[i-1] == 'C') s[i] = s[i-1]+1; else s[i] = s[i-1] - 1; int q; cin >> q; while(q--){ int l, r; cin >> l >> r; int S = 0; int M = 0; for(int i = l - 1; i <= r; i++){ if(s[i] + S < s[l - 1]){ S++; M = max(0, M-1); } if(s[i] > s[r]){ M = max(M, s[i] - s[r]); } } cout << S + M << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 488 KB | Output is correct |
3 | Correct | 8 ms | 636 KB | Output is correct |
4 | Correct | 11 ms | 660 KB | Output is correct |
5 | Correct | 10 ms | 876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 488 KB | Output is correct |
3 | Correct | 8 ms | 636 KB | Output is correct |
4 | Correct | 11 ms | 660 KB | Output is correct |
5 | Correct | 10 ms | 876 KB | Output is correct |
6 | Correct | 1919 ms | 2584 KB | Output is correct |
7 | Execution timed out | 3048 ms | 3204 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 488 KB | Output is correct |
3 | Correct | 8 ms | 636 KB | Output is correct |
4 | Correct | 11 ms | 660 KB | Output is correct |
5 | Correct | 10 ms | 876 KB | Output is correct |
6 | Correct | 1919 ms | 2584 KB | Output is correct |
7 | Execution timed out | 3048 ms | 3204 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |