| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 759339 | gvancak | Election (BOI18_election) | C++11 | 3064 ms | 26144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define s second
#define f first
#define pb push_back
using namespace std;
ll n,k,a[1000005],b[1000005],dp[1000005],ans[1000005],mx,l,z,x,q,r;
map <ll,ll> m;
vector <ll> v[1000005];
string s;
bool ok;
int main()
{
cin>>n;
cin>>s;
for (int i=0; i<s.size(); i++)
if (s[i]=='C') a[i+1]=1;
else a[i+1]=-1;
for (int i=1; i<=n; i++) b[i]=a[i];
//prefix da sufix a[i]>=0 gvinda
cin>>q;
for (int o=1; o<=q; o++){
cin>>l>>r;
x=0; k=0;
for (int i=l; i<=r; i++){
x+=b[i];
if (x<0){
b[i]=0; k++; x=0;
}
}
x=0;
for (int i=r; i>=l; i--){
x+=b[i];
if (x<0){
b[i]=0; k++; x=0;
}
}
cout<<k<<endl;
for (int i=1; i<=n; i++) b[i]=a[i];
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
