import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N=sc.nextInt(); long[] A=new long[N+1]; long[] B=new long[N+1]; long[] D=new long[N]; for(int i=0;i<=N;++i){ A[i]=sc.nextLong(); } for(int i=0;i<=N;++i){ B[i]=sc.nextLong(); } for(int i=0;i1){ int middle=(ok+ng)/2; if(check(A,B,D,middle)){ ok=middle; }else{ ng=middle; } } System.out.println(ok); } boolean check(long[] A, long[] B, long[] D, int curn){ int N=D.length; boolean[][] dp=new boolean[N+1][N+1]; for(int i=0;iN)continue; if(D[curn-i]<=A[a]+B[b]){ if(a>0) dp[i][a]|=dp[i-1][a-1]; if(b>0) dp[i][a]|=dp[i-1][a]; } } } int ans=0; for(int i=0;i<=N;++i){ for(int j=0;j<=N;++j){ if(dp[i][j]) ans=Math.max(ans,i); } } return ans>=curn; } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }