QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133447 | #4931. Comic Binge | nameless_story# | WA | 1ms | 3604kb | C++17 | 880b | 2023-08-02 09:32:34 | 2023-08-02 09:32:37 |
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;
}
}
cout<<ans<<'\n';
}
詳細信息
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: 3472kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3468kb
input:
1 1 1
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'