/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 488.0 KiB
#3 Wrong Answer 45ms 616.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<int>> a(2, vector<int>(n));
    for(int i=0; i<2; i++)
        for(int j=0; j<n; j++)
            cin >> a[i][j];

    vector<vector<int>> dp(2, vector<int>(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:26:24
Judged At
2024-11-11 03:32:14
Judged By
Score
0
Total Time
45ms
Peak Memory
616.0 KiB