# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68299 | 2018-08-16T12:16:30 Z | Bruteforceman | Election (BOI18_election) | C++11 | 3000 ms | 2872 KB |
#include "bits/stdc++.h" using namespace std; int a[500010]; int p[500010]; int solve(int l, int r) { int cur = 0; int ans = 0; int mx = 0; int mn = 0; for(int i = l; i <= r; i++) { cur += a[i]; mn = min(mn, cur); mx = max(mx, cur - mn); } ans -= mn; ans += mx - (cur - mn); return ans; } char s[500010]; int main(int argc, char const *argv[]) { int n; scanf("%d", &n); scanf("%s", s); for(int i = 1; i <= n; i++) { a[i] = s[i - 1] == 'C' ? 1 : -1; } int q; scanf("%d", &q); while(q--) { int l, r; scanf("%d %d", &l, &r); printf("%d\n", solve(l, r)); } return 0; } // CCCTTTTTTCC // CCCTTTCC
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 516 KB | Output is correct |
4 | Correct | 5 ms | 540 KB | Output is correct |
5 | Correct | 6 ms | 568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 516 KB | Output is correct |
4 | Correct | 5 ms | 540 KB | Output is correct |
5 | Correct | 6 ms | 568 KB | Output is correct |
6 | Correct | 1844 ms | 2356 KB | Output is correct |
7 | Execution timed out | 3047 ms | 2872 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 516 KB | Output is correct |
4 | Correct | 5 ms | 540 KB | Output is correct |
5 | Correct | 6 ms | 568 KB | Output is correct |
6 | Correct | 1844 ms | 2356 KB | Output is correct |
7 | Execution timed out | 3047 ms | 2872 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |