# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
770165 | 2023-06-30T21:31:36 Z | allllekssssa | Election (BOI18_election) | C++14 | 5 ms | 340 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; for (int i = l; i <= r; i++) { if (s[i - 1] == 'T') ++cur; else cur--; d[i] = max(0, cur); } cur = 0; for (int i = r; i>=l; i--) { d[i]+=max(0, cur); if (s[i - 1] == 'T') ++cur; else 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 | Incorrect | 5 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |