QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133675 | #4931. Comic Binge | wtn135687# | WA | 1ms | 3492kb | C++14 | 810b | 2023-08-02 12:49:04 | 2023-08-02 12:49:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N = 1e3+10,mo = 1e9+7;
int a[N],b[N];
int pre[N],suf[N];
int dp1[N],dp2[N];
inline void solve(){
int n;
cin>>n;
for(int i=1;i<=n;++i) cin>>a[i],pre[i]=pre[i-1]+a[i];
for(int i=1;i<=n;++i) cin>>b[i];
for(int i=n;i>=1;--i) suf[i]=suf[i+1]+a[i];
dp1[n+1]=mo,dp2[0]=mo,dp1[n]=a[n]+b[n];
for(int i=n-1;i>=1;--i){
dp1[i]=max(min(dp1[i+1],dp1[i+2]),suf[i])+b[i];
}
for(int i=2;i<=n;++i){
dp2[i]=max(min(dp2[i+1],dp2[i+2]),pre[i])+b[i];
}
cout<<min(dp1[1],dp2[n])<<endl;
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int WTN666=1;//cin>>WTN666;
while(WTN666--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3480kb
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: 3492kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3428kb
input:
1 1 1
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'