/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Wrong Answer 2ms 540.0 KiB
#3 Wrong Answer 75ms 628.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'
const int N = 2e5+4;


void solve(int cs){
    int n;
    cin >> n;
    vector<vector<ll>> a(2, vector<ll>(n));
    for(int i=0; i<2; i++)
        for(int j=0; j<n; j++)
            cin >> a[i][j];

    vector<vector<ll>> dp(2, vector<ll>(n, -1e17));
    dp[0][0] = a[0][0];
    dp[1][0] = a[0][0] + a[1][0];

    for(int j=1; j<n; j++) {
        dp[0][j] = max(dp[0][j], dp[0][j-1] + a[0][j]);
        dp[0][j] = max(dp[0][j], dp[1][j-1] + a[0][j]);
        dp[1][j] = max(dp[1][j], dp[0][j-1] + a[1][j]);
        dp[1][j] = max(dp[1][j], dp[1][j-1] + a[1][j]);
    }

    cout <<  dp[1][n-1] << endl;
}
   
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);
    int t=1,cs=0;
    cin >> t;
    while(t--)
    {
        solve(++cs);
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1050 Game on 2d grid
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 17:27:12
Judged At
2024-11-11 03:32:13
Judged By
Score
0
Total Time
75ms
Peak Memory
628.0 KiB