QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#319003 | #4931. Comic Binge | owen0806# | WA | 2ms | 6748kb | C++20 | 872b | 2024-02-01 14:55:15 | 2024-02-01 14:55:16 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define PB push_back
#define pii pair<int, int>
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e18;
int a[N], b[N], dp[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];
memset(dp, 0x3f, sizeof(dp));
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];
}
dp[n][1] = min(dp[n-1][0], dp[n-1][1]) + b[n];
int ans = 0;
for(int i=1; i<=n; i++){
ans = max(min(dp[i][0], dp[i][1]), ans) + a[i];
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while(T--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 6748kb
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: 2ms
memory: 6680kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 6664kb
input:
1 1 1
output:
4557430888798830400
result:
wrong answer 1st lines differ - expected: '2', found: '4557430888798830400'