# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
63540 | 2018-08-02T05:59:57 Z | antimirage | Election (BOI18_election) | C++17 | 20 ms | 1100 KB |
#include <iostream> #include <assert.h> #include <stdio.h> #include <iomanip> #include <utility> #include <math.h> #include <time.h> #include <vector> #include <set> #include <map> #define fr first #define sc second #define mk make_pair #define pb push_back #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() using namespace std; const int N = 2005; int n, q, pref[N], suf[N], l, r, sum[N], ans, cn; string s; main() { cin >> n >> s; s = ' ' + s; for (int i = 1; i <= n; i++) pref[i] = (s[i] == 'C' ? 1 : -1) + pref[i - 1]; for (int i = n; i >= 1; i--) suf[i] = (s[i] == 'C' ? 1 : -1) + suf[i + 1]; cin >> q; while (q--) { cn = 0; ans = 0; for (int i = 1; i<= n; i++) sum[i] = 0; scanf("%d%d", &l, &r); for (int i = l; i <= r; i++) { if ( pref[i] + cn < pref[l - 1] ) { cn++; sum[l] += 1; sum[i + 1] -= 1; ans++; } } for (int i = 1; i<= n; i++) sum[i] += sum[i - 1]; cn = 0; for (int i = r; i >= l; i--) { if ( sum[i] + suf[i] < suf[r + 1] - cn) ans++, cn++; } printf("%d\n", ans); // system("pause"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 376 KB | Output is correct |
2 | Correct | 19 ms | 376 KB | Output is correct |
3 | Correct | 19 ms | 452 KB | Output is correct |
4 | Correct | 19 ms | 484 KB | Output is correct |
5 | Correct | 18 ms | 576 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 376 KB | Output is correct |
2 | Correct | 19 ms | 376 KB | Output is correct |
3 | Correct | 19 ms | 452 KB | Output is correct |
4 | Correct | 19 ms | 484 KB | Output is correct |
5 | Correct | 18 ms | 576 KB | Output is correct |
6 | Runtime error | 7 ms | 1100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 376 KB | Output is correct |
2 | Correct | 19 ms | 376 KB | Output is correct |
3 | Correct | 19 ms | 452 KB | Output is correct |
4 | Correct | 19 ms | 484 KB | Output is correct |
5 | Correct | 18 ms | 576 KB | Output is correct |
6 | Runtime error | 7 ms | 1100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Halted | 0 ms | 0 KB | - |