/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 484.0 KiB
#2 Wrong Answer 2ms 488.0 KiB
#3 Wrong Answer 42ms 660.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e6+10,MOD=1000000007;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<vector<ll>>dp(3,vector<ll>(n+1,0));
        for(int i=1;i<=2;i++){
            for(int j=1;j<=n;j++)cin>>dp[i][j];
        }
       for(int i=1;i<=n;i++){
          if(i==1)continue;
          if(i==n){
            dp[1][i]+=dp[1][i-1];
            continue;
          }
          dp[1][i]=max((ll)i*(-1),dp[1][i])+dp[1][i-1];
       }
       for(int i=1;i<=n;i++){
           if(i==1){
            dp[2][i]+=dp[1][i];
            continue;
          }
          if(i==n){
            dp[2][i]+=max(dp[1][i],dp[2][i-1]);
            continue;
          }
          ll value=dp[2][i];
          dp[2][i]=max(dp[1][i]+value,dp[2][i-1]+max(value,(ll)-i));

       }
       cout<<dp[2][n]<<"\n";
       
    }
    
    
   
   return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1050 Game on 2d grid
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-03 11:29:46
Judged At
2024-11-11 03:35:54
Judged By
Score
0
Total Time
42ms
Peak Memory
660.0 KiB