# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
770176 | 2023-06-30T22:40:51 Z | allllekssssa | Election (BOI18_election) | C++14 | 3000 ms | 1052 KB |
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; const int maxN = 100000; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 320 KB | Output is correct |
3 | Correct | 4 ms | 212 KB | Output is correct |
4 | Correct | 4 ms | 212 KB | Output is correct |
5 | Correct | 4 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 320 KB | Output is correct |
3 | Correct | 4 ms | 212 KB | Output is correct |
4 | Correct | 4 ms | 212 KB | Output is correct |
5 | Correct | 4 ms | 212 KB | Output is correct |
6 | Execution timed out | 3070 ms | 1052 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 320 KB | Output is correct |
3 | Correct | 4 ms | 212 KB | Output is correct |
4 | Correct | 4 ms | 212 KB | Output is correct |
5 | Correct | 4 ms | 212 KB | Output is correct |
6 | Execution timed out | 3070 ms | 1052 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |