/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 320.0 KiB
#3 Wrong Answer 102ms 664.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define m(a,b,c) max(a,max(b,c))
#define N ll n;cin >> n;
#define Nk ll n,k;cin >> n >> k;
#define A ll a[n];f(i,n) cin >> a[i];
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr);
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define S string s;cin>>s;
#define pb push_back

int main()
{
   FAST_IO;
   ll t;
   cin>>t;
   while(t--)
   {
        N;
        ll a[3][n+1];
        memset(a,0,sizeof(a));
        for(ll i=1;i<=2;i++)
        {
            for(ll j=1;j<=n;j++)
            {
                ll x;
                cin>>x;
                if(j!=1 && j!=n && x+j<0)
                {
                    x=-j;
                }
                a[i][j]=x;
            }
        }
        ll dp[3][n+1];
        memset(dp,0,sizeof(dp));
        for(ll i=1;i<=2;i++)
        {
            for(ll j=1;j<=n;j++)
            {
                if(i==2 && j>1)
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
                else if(i==2 && j==1)
                {
                    dp[2][1]=a[1][1]+a[2][1];
                }
                else
                {
                    dp[i][j]=dp[i][j-1]+a[i][j];
                }
            }
        }
        cout<<dp[2][n]<<endl;
   }
   
   return 0;
}

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 17:13:10
Judged At
2024-11-11 03:32:28
Judged By
Score
0
Total Time
102ms
Peak Memory
664.0 KiB