# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870362 | 2023-11-07T13:33:51 Z | Alora | Election (BOI18_election) | C++17 | 3000 ms | 1408 KB |
#include <bits/stdc++.h> #define Alora "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define f first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define all(v) v.begin(), v.end() #define pb push_back #define maxn 300005 const int M = 1e9 + 7; using namespace std; int n, q, xd[maxn]; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); if(fopen(Alora".inp","r")){ freopen(Alora".inp","r",stdin); freopen(Alora".out","w",stdout);} cin >> n >> s; s = ' ' + s; cin >> q; while(q--){ int l, r; cin >> l >> r; fi(i, 1, n) xd[i] = 0; int c = 0, t = 0; fi(i, l, r){ if(s[i] == 'C') c++; else{ if(t < c) t++; else xd[i] = 1; } } c = t = 0; fid(i, r, l){ if(s[i] == 'C') c++; else if(xd[i] == 0){ if(t < c) t++; else xd[i] = 1; } } int ans = 0; fi(i, 1, n) ans += xd[i]; cout << ans << '\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 476 KB | Output is correct |
3 | Correct | 7 ms | 348 KB | Output is correct |
4 | Correct | 9 ms | 500 KB | Output is correct |
5 | Correct | 4 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 476 KB | Output is correct |
3 | Correct | 7 ms | 348 KB | Output is correct |
4 | Correct | 9 ms | 500 KB | Output is correct |
5 | Correct | 4 ms | 348 KB | Output is correct |
6 | Execution timed out | 3063 ms | 1408 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 476 KB | Output is correct |
3 | Correct | 7 ms | 348 KB | Output is correct |
4 | Correct | 9 ms | 500 KB | Output is correct |
5 | Correct | 4 ms | 348 KB | Output is correct |
6 | Execution timed out | 3063 ms | 1408 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |