Submission #1227866

#TimeUsernameProblemLanguageResultExecution timeMemory
1227866Sir_Ahmed_ImranElection (BOI18_election)C++17
28 / 100
3094 ms1220 KiB
// 01001100 01001111 01010100 01000001 \\ // \\ // ╦ ╔═╗╔╦╗╔═╗ \\ // ║ ║ ║ ║ ╠═╣ \\ // ╩═╝╚═╝ ╩ ╩ ╩ \\ // \\ // 01001100 01001111 01010100 01000001 \\ #include <bits/stdc++.h> using namespace std; #define N 500001 #define nl '\n' #define ff first #define ss second #define ll long long #define ld long double #define terminator main #define pll pair<ll,ll> #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) int a[N]; bool vis[N]; void solve(){ string s; int n, q, l, r, o, x; cin >> n >> s; for(int i = 0; i < n; i++){ if(s[i] == 'C') a[i + 1] = 1; else a[i + 1] = - 1; } cin >> q; while(q--){ cin >> l >> r; o = x = 0; for(int i = l; i <= r; i++){ if(a[i] + o < 0){ vis[i] = 1; x++; } else o += a[i]; } o = 0; for(int i = r; i >= l; i--){ if(vis[i]) vis[i] = 0; else if(a[i] + o < 0) x++; else o += a[i]; } cout << x << nl; } } int terminator(){ L0TA; solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...