QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#319639 | #4931. Comic Binge | fivefive | WA | 0ms | 3640kb | C++14 | 1.0kb | 2024-02-02 21:56:28 | 2024-02-02 21:56:30 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define PB push_back
#define pii pair<int, int>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e18;
int a[N], b[N], dp[N][2], dp2[N][2];
void solve(){
int n;
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i];
for(int i=1; i<=n; i++) cin >> b[i];
dp[1][0] = INF;
dp[1][1] = b[1];
for(int i=2; i<=n; i++){
dp[i][0] = dp[i-1][1];
dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + b[i];
}
dp2[1][0] = 0;
dp2[1][1] = a[1] + b[1];
for(int i=2; i<=n; i++){
dp2[i][0] = max(dp[i][0], dp2[i-1][1]) + a[i];
dp2[i][1] = max(dp[i][1], max(dp2[i-1][0], dp2[i-1][1])) + a[i];
//cout << dp2[i][0] << " " << dp2[i][1] << endl;
}
cout << dp2[n][1] << endl;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while(T--){
solve();
}
//testing
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3640kb
input:
6 3 1 1 1 1 2 1 5 3 3 7 4
output:
14
result:
wrong answer 1st lines differ - expected: '13', found: '14'