/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 600.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 62ms 572.0 KiB
#4 Accepted 51ms 600.0 KiB
#5 Accepted 45ms 596.0 KiB
#6 Accepted 50ms 632.0 KiB
#7 Accepted 47ms 540.0 KiB
#8 Accepted 42ms 1.172 MiB
#9 Accepted 26ms 1.074 MiB

Code

/*
 *   Copyright (c) 2024 Emon Thakur
 *   All rights reserved.
 */
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

//ofstream file("output0.txt");

void solve()
{
    int n; cin>>n;
    ll a[2][n+1]={0}, b[2][n+1];
    a[0][0]=0;
    a[1][0]=0;
    for(int i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>b[i][j];
            a[i][j] = max(b[i][j],j*(-1));
        }
    }
    a[1][n] = b[1][n];
    a[0][1] = b[0][1];

    for(int i=2;i<=n;i++) a[0][i] += a[0][i-1];
    for(int i=2;i<=n;i++) a[1][i] += a[1][i-1];

    //ll score = b[0][1]+b[1][1]+(a[1][n]-a[1][1]);
    ll score = -1e18;
    for(int i=2;i<=n;i++)
    {
        score = max(score , (a[0][i-1]+b[0][i]+b[1][i]+(a[1][n]-a[1][i])));
    }

    
    cout<<score<<endl;
    //file<<score<<endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //freopen("input0.txt","r",stdin);
    int t; cin>>t; while(t--) solve();
}

Information

Submit By
Type
Submission
Problem
P1050 Game on 2d grid
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-03 21:46:19
Judged At
2024-05-03 21:46:19
Judged By
Score
100
Total Time
62ms
Peak Memory
1.172 MiB