QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#319003#4931. Comic Bingeowen0806#WA 2ms6748kbC++20872b2024-02-01 14:55:152024-02-01 14:55:16

Judging History

你现在查看的是最新测评结果

  • [2024-02-01 14:55:16]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6748kb
  • [2024-02-01 14:55:15]
  • 提交

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'