Submission #433797

#TimeUsernameProblemLanguageResultExecution timeMemory
433797AmineTrabelsiElection (BOI18_election)C++14
0 / 100
8 ms204 KiB
#include "bits/stdc++.h" using namespace std; // Hi int l,r; int main(){ ios::sync_with_stdio(0);cin.tie(0); int n; cin>>n; string s; cin>>s; int q; cin>>q; while(q--){ cin>>l>>r; l--,r--; vector<int> suff(n+1,0); for(int i=r;i>=l;i--){ suff[i] = suff[i+1]+(s[i] == 'C'); } int t = 0; int c = 0; int ans = 0; for(int i=l;i<=r;i++){ if(s[i] == 'T'){ if(t+1 <= suff[i])t++; else ans++; }else { if(t > 0)t--; } } cout << ans << '\n'; } return 0; }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:22:13: warning: unused variable 'c' [-Wunused-variable]
   22 |         int c = 0;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...