# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105888 | 2019-04-15T14:32:47 Z | IOrtroiii | Election (BOI18_election) | C++14 | 3000 ms | 1688 KB |
#include <bits/stdc++.h> using namespace std; const int N = 500500; char s[N]; bool del[N]; int brute(int l,int r) { int nw = 0; int ans = 0; for (int i = l; i <= r; ++i) { nw += (s[i] == 'C' ? +1 : -1); if (nw < 0) { ++ans; del[i] = true; nw = 0; } } nw = 0; for (int i = r; i >= l; --i) { if (del[i]) continue; nw += (s[i] == 'C' ? +1 : -1); if (nw < 0) { ++ans; del[i] = true; nw = 0; } } for (int i = l; i <= r; ++i) del[i] = false; return ans; } int main() { int n; scanf("%d %s", &n, s + 1); int q; scanf("%d", &q); for (int i = 1; i <= q; ++i) { int l, r; scanf("%d %d", &l, &r); printf("%d\n", brute(l, r)); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 396 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 404 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 396 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 404 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 304 KB | Output is correct |
6 | Execution timed out | 3100 ms | 1688 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 396 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 404 KB | Output is correct |
4 | Correct | 8 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 304 KB | Output is correct |
6 | Execution timed out | 3100 ms | 1688 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |