# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
770175 | 2023-06-30T22:40:16 Z | allllekssssa | Election (BOI18_election) | C++14 | 5 ms | 980 KB |
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; const int maxN = 3000; string s; int n, q; int d[maxN]; int main() { cin >> n; cin >> s; cin >> q; while(q--) { int l, r; scanf("%d%d", &l, &r); int cur = 0; int mm = 0; for (int i = l; i <= r; i++) { if (s[i - 1] == 'T') ++cur; else cur--; mm = max(mm, cur); d[i] = mm; } cur = 0; mm = 0; for (int i = r; i>=l; i--) { d[i]+=mm; if (s[i - 1] == 'T') ++cur; else cur--; mm = max(mm, cur); } int mx = 0; for (int i = l; i<=r; i++) { mx = max(mx, d[i]); } printf("%d\n", mx); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 316 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 4 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 316 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 4 ms | 340 KB | Output is correct |
6 | Runtime error | 2 ms | 980 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 316 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 4 ms | 340 KB | Output is correct |
6 | Runtime error | 2 ms | 980 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |