| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1368077 | piolk | Election (BOI18_election) | C++20 | 3093 ms | 688 KiB |
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,q;
string s;
cin>>n>>s>>q;
while (q--){
int l,r;
cin>>l>>r;
l--; r--;
vector<bool> del(n);
int bal=0;
for (int i=l;i<=r;i++){
bal+=(s[i]=='C' ? 1 : -1);
if (bal<0){
del[i]=true;
bal=0;
}
}
bal=0;
for (int i=r;i>=l;i--){
if (del[i]) continue;
bal+=(s[i]=='C' ? 1 : -1);
if (bal<0){
del[i]=true;
bal=0;
}
}
int ans=0;
for (int i=0;i<n;i++) ans+=del[i];
cout<<ans<<"\n";
}
return 0;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
