Submission #60901

#TimeUsernameProblemLanguageResultExecution timeMemory
60901spencercomptonElection (BOI18_election)C++14
28 / 100
3011 ms1220 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; int q; cin >> q; for(int i = 0; i<q; i++){ bool use[n]; for(int j = 0; j<n; j++){ use[j] = true; } int cur = 0; int l, r; cin >> l >> r; l--; r--; int ans = 0; for(int j = l; j<=r; j++){ if(s[j]=='T' && cur==0){ ans++; use[j] = false; } else if(s[j]=='T'){ cur--; } else{ cur++; } } cur = 0; for(int j = r; j>=l; j--){ if(s[j]=='T' && cur==0 && use[j]){ use[j] = false; ans++; } else if(s[j]=='T' && use[j]){ cur--; } else if(s[j]=='C'){ cur++; } } cout << ans << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...