# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61698 | 2018-07-26T11:08:46 Z | onjo0127(#1771) | Election (BOI18_election) | C++11 | 3000 ms | 760 KB |
#include <bits/stdc++.h> using namespace std; char A[500009]; bool chk[500009]; int main() { int N, Q; scanf("%d\n%s%d", &N, A+1, &Q); while(Q--) { int l, r, ans = 0; scanf("%d%d",&l,&r); for(int i=l, s=0; i<=r; i++) { if(A[i] == 'C') ++s; else --s; if(s < 0) chk[i] = 1, ++s, ++ans; } for(int i=r, s=0; i>=l; i--) { if(A[i] == 'C') ++s; else --s; if(chk[i]) ++s; if(s < 0) ++s, ++ans; } for(int i=l; i<=r; i++) chk[i] = 0; printf("%d\n",ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 248 KB | Output is correct |
2 | Correct | 15 ms | 356 KB | Output is correct |
3 | Correct | 12 ms | 452 KB | Output is correct |
4 | Correct | 12 ms | 452 KB | Output is correct |
5 | Correct | 11 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 248 KB | Output is correct |
2 | Correct | 15 ms | 356 KB | Output is correct |
3 | Correct | 12 ms | 452 KB | Output is correct |
4 | Correct | 12 ms | 452 KB | Output is correct |
5 | Correct | 11 ms | 504 KB | Output is correct |
6 | Execution timed out | 3099 ms | 760 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 248 KB | Output is correct |
2 | Correct | 15 ms | 356 KB | Output is correct |
3 | Correct | 12 ms | 452 KB | Output is correct |
4 | Correct | 12 ms | 452 KB | Output is correct |
5 | Correct | 11 ms | 504 KB | Output is correct |
6 | Execution timed out | 3099 ms | 760 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |