/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Wrong Answer 2ms 496.0 KiB
#3 Wrong Answer 59ms 644.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;
    ll arr[5][n+5];
    for(int i = 1; i <= 2; i++){
        for(int j = 0; j <= n; j++)arr[i][j]=0;
        //cout<<endl;
    }
    for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= n; j++)cin>>arr[i][j];
    }
    
    
    /*for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= n; j++)cout<<arr[i][j]<<" ";
        cout<<endl;
    }*/
    
    for(ll i = 1; i <= n; i++){
        arr[1][i] = max(arr[1][i],-i) + arr[1][i-1]; 
    }
    for(ll i = 1; i < n; i++){
        arr[2][i] = max(arr[2][i],-i) + arr[2][i-1]; 
    }
    arr[2][n] += arr[2][n-1];
    
    /*for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= n; j++)cout<<arr[i][j]<<" ";
        cout<<endl;
    }*/
    
    ll ans = -1e17;
    
    for(int i = 1; i<= n; i++){
        ans = max(ans, arr[1][i]+arr[2][n]-arr[2][i-1]);
    }
    cout<<ans<<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:13:38
Judged At
2024-11-11 03:32:26
Judged By
Score
0
Total Time
59ms
Peak Memory
644.0 KiB