QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#319636#4931. Comic BingefivefiveWA 1ms9784kbC++141.0kb2024-02-02 21:52:112024-02-02 21:52:11

Judging History

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

  • [2024-02-02 21:52:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9784kb
  • [2024-02-02 21:52:11]
  • 提交

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: 1ms
memory: 9784kb

input:

6
3 1 1 1 1 2
1 5 3 3 7 4

output:

5 7
8 8
9 9
10 12
14 14
14

result:

wrong answer 1st lines differ - expected: '13', found: '5 7'