# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63538 | 2018-08-02T05:57:57 Z | antimirage | Election (BOI18_election) | C++17 | 21 ms | 248 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 = suf[r + 1]; for (int i = r; i >= l; i--) { if ( sum[i] + suf[i] < suf[r + 1] && s[i] == 'T') ans++, cn = suf[i]; } printf("%d\n", ans); // system("pause"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |