Submission #565583

#TimeUsernameProblemLanguageResultExecution timeMemory
565583AbdullahMWElection (BOI18_election)C++14
0 / 100
7 ms212 KiB
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define ll long long #define db double #define pb push_back #define pf push_front #define newl "\n" #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define f first #define s second #define MOD 1000000007 using namespace std; int main() { fast //setIO(""); //freopen("filename.in", "r", stdin); //freopen("filename.out", "w", stdout); ll n; cin >> n; string s; cin >> s; ll q; cin >> q; while (q--) { ll l, r; cin >> l >> r; l--, r--; ll c = 0, t = 0, cnt1 = 0; for (ll i = l; i <= r; i++) { if (s[i] == 'C') c++; else t++; if (t > c) { t--; cnt1++; } } c = 0, t = 0; ll cnt2 = 0; for (ll i = r; i >= l; i--) { if (s[i] == 'C') c++; else t++; if (t > c) { t--; cnt2++; } } cout << max(cnt1, cnt2) << newl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...