QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133453 | #4931. Comic Binge | nameless_story# | RE | 1ms | 3604kb | C++17 | 900b | 2023-08-02 09:37:29 | 2023-08-02 09:37:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 30000
int a[N],b[N],f[N],sa[N];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int n; cin>>n;
for (int i=1;i<=n;++i){
cin>>a[i];
sa[i]=sa[i-1]+a[i];
}
for (int i=1;i<=n;++i){
cin>>b[i];
}
int mx=sa[n]+n*10;
int l=b[1]+sa[n],r=mx;
int ans=0;
auto check=[&](int k){
f[0]=k+1; f[1]=b[1];
f[n]=k+1;
for (int i=2;i<=n;++i){
f[i]=min(f[i-1],f[i-2])+b[i];
if (f[i]+sa[n]-sa[i-1]>k) f[i]=k+1;
if (f[i]==k+1&&f[i-1]==k+1) return 0;
}
return int(f[n]<=k);
};
while (l<=r){
int mid=(l+r)>>1;
if (check(mid)){
ans=mid; r=mid-1;
}
else{
l=mid+1;
}
}
assert(ans>0);
cout<<ans<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
6 3 1 1 1 1 2 1 5 3 3 7 4
output:
13
result:
ok single line: '13'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Dangerous Syscalls
input:
1 1 1