# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
793107 | pasin30055 | Election (BOI18_election) | C++14 | 6 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cstdlib>
#include <iostream>
#define MAXN 2005
using namespace std;
int n, q, l, r;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];
char s[MAXN];
int main() {
scanf("%d\n%s\n%d", &n, s, &q);
for (; q > 0; q --) {
scanf("%d %d", &l, &r);
a[l - 1] = 0;
b[r + 1] = 0;
c[l - 1] = 0;
d[r + 1] = 0;
int ans = 0;
for (int i = l ; i <= r ; i ++) {
a[i] = a[i - 1];
if (s[i - 1] == 'C') a[i]--;
else a[i]++;
c[i] = max(c[i - 1], a[i]);
}
for (int i = r ; i >= l; i --) {
b[i] = b[i + 1];
if (s[i - 1] == 'C') b[i]--;
else b[i]++;
d[i] = max(d[i + 1], b[i]);
ans = max(ans, d[i + 1] + c[i]);
}
printf("%d\n", ans);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |