Submission #137568

#TimeUsernameProblemLanguageResultExecution timeMemory
137568mechfrog88Election (BOI18_election)C++14
0 / 100
20 ms376 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; typedef long double ld; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,q; cin >> n; string a; cin >> a; cin >> q; for (int z=0;z<q;z++){ ll l,r; cin >> l >> r; l--;r--; ll c = 0; ll t = 0; ll ans1 = 0,ans2 = 0; for (int x=l;x<=r;x++){ if (a[x] == 'C'){ c++; } else { t++; } if (t > c){ t--; ans1++; } } c = 0; t = 0; for (int x=r;x>=l;x--){ if (a[x] == 'C'){ c++; } else { t++; } if (t > c){ t--; ans2++; } } cout << max(ans1,ans2) << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...