Please read the new rule regarding the restriction on the use of AI tools. ×

piyush_bh_'s blog

By piyush_bh_, 17 months ago, In English

include <bits/stdc++.h>

using namespace std;

define ll long long

define int signed long long

define pb emplace_back

define inf 1e18

define all(x) (x).begin(), (x).end()

define loop(i,a,n,b) for(long long i=a;i<n;i+=b)

define reloop(i,a,n,b) for(long long i=a;i>=n;i-=b)

define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){ int n; cin>>n; if(n==1){ cout<<0<<"\n";return; } int arr[2][n]; int up[n]; int down[n]; loop(i,0,2,1){ loop(j,0,n,1){ cin>>arr[i][j]; } } int sum=0; reloop(i,n-1,0,1){ sum+=arr[0][i]; up[i]=sum; } sum=0; loop(i,0,n,1){ sum+=arr[1][i]; down[i]=sum; } vectorv; loop(i,0,n,1){ if(i==0){ v.pb(up[1]); continue; } if(i==n-1){ v.pb(down[n-2]); continue; } int ans=max(up[i+1],down[i-1]); v.pb(ans); } cout<<*min_element(all(v))<<"\n"; }

signed main(){ fast; int t=1; cin>>t; while(t--){ solve(); } return 0; }

  • Vote: I like it
  • -9
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it +2 Vote: I do not like it

.