# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61540 | 2018-07-26T07:22:49 Z | 김세빈(#1779) | Election (BOI18_election) | C++11 | 3000 ms | 1116 KB |
#include <bits/stdc++.h> using namespace std; char str[505050]; bool chk[505050]; int n; int main() { int q, i, l, r, k, s, minv; scanf("%d%s%d", &n, str, &q); for(; q--; ){ scanf("%d%d", &l, &r); k = s = minv = 0; for(i=l; i<=r; i++){ if(str[i-1] == 'C') s ++; else s --; if(s < minv) minv = s, k ++, chk[i] = 1; } s = 0; for(i=r; i>=l; i--){ if(str[i-1] == 'C') s ++; else if(!chk[i]){ if(s == 0) k ++; else s --; } else chk[i] = 0; } printf("%d\n", k); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 376 KB | Output is correct |
2 | Correct | 15 ms | 504 KB | Output is correct |
3 | Correct | 16 ms | 504 KB | Output is correct |
4 | Correct | 13 ms | 588 KB | Output is correct |
5 | Correct | 8 ms | 588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 376 KB | Output is correct |
2 | Correct | 15 ms | 504 KB | Output is correct |
3 | Correct | 16 ms | 504 KB | Output is correct |
4 | Correct | 13 ms | 588 KB | Output is correct |
5 | Correct | 8 ms | 588 KB | Output is correct |
6 | Execution timed out | 3030 ms | 1116 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 376 KB | Output is correct |
2 | Correct | 15 ms | 504 KB | Output is correct |
3 | Correct | 16 ms | 504 KB | Output is correct |
4 | Correct | 13 ms | 588 KB | Output is correct |
5 | Correct | 8 ms | 588 KB | Output is correct |
6 | Execution timed out | 3030 ms | 1116 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |