제출 #1026543

#제출 시각아이디문제언어결과실행 시간메모리
1026543vjudge1Election (BOI18_election)C++17
28 / 100
3051 ms1108 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin>>n; string a; cin>>a>>q; while(q--) { int l, r, c=0, p=0, rez=0; cin>>l>>r; l--, r--; for(int i=l; i<=r; i++) { if(a[i]=='C') c++; else if(a[i]=='T') p++; if(p>c) { a[i]='#'; p--; rez++; } } c=0, p=0; for(int i=r; i>=l; i--) { if(a[i]=='C') c++; else if(a[i]=='T') p++; if(p>c) { p--; rez++; } if(a[i]=='#') a[i]='T'; } cout<<rez<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...