/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 162ms 608.0 KiB

Code

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

int main(){
  int t;
  cin >> t;
  while (t--){
    int n;
    cin >> n;
    ll a[2][n + 1], dp[2][n + 1];
    for (int i = 0; i < 2; i++){
      for (int j = 1; j <= n; j++){
        cin >> a[i][j];
        dp[i][j] = 0;
      }
    }
    dp[0][0] = dp[1][0] = -1e18;
    dp[0][1] = a[0][1];
    for (int i = 1; i <= n; i++){
      if (i > 1) dp[0][i] = dp[0][i - 1] + max(a[0][i], 1LL * (-i));
      if (i < n) dp[1][i] = max(dp[0][i] + a[1][i], dp[1][i - 1] + max(a[1][i], 1LL * (-i)));
    }
    cout << max(dp[0][n], dp[1][n - 1]) + a[1][n] << endl;
  }
}

Information

Submit By
Type
Submission
Problem
P1050 Game on 2d grid
Contest
Brain Booster #3
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-06 16:59:58
Judged At
2024-11-11 03:32:38
Judged By
Score
0
Total Time
162ms
Peak Memory
608.0 KiB