/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Wrong Answer 34ms 612.0 KiB
#4 Wrong Answer 23ms 576.0 KiB
#5 Wrong Answer 31ms 568.0 KiB
#6 Wrong Answer 36ms 648.0 KiB
#7 Wrong Answer 43ms 592.0 KiB
#8 Accepted 39ms 1.312 MiB
#9 Wrong Answer 29ms 1.387 MiB

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];
    int s[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];
            if(i == 2)s[j] = 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]+s[i]);
    }
    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:16:53
Judged At
2024-10-03 13:48:52
Judged By
Score
20
Total Time
43ms
Peak Memory
1.387 MiB