import java.io.*; import java.util.*; class Main { static long cube(long x){return x*x*x;} Main(){} long[] solveNaive(long[]a,long[]x,long[]y){ int n=a.length; long[]dp=new long[n+1]; Arrays.fill(dp,Long.MAX_VALUE); dp[0]=0; for(int i=0;i1){ int middle=(pass+fail)/2; long value1=dp[i]+cube(Math.abs(a[middle]-x[i]))+cube(y[i]); long value2=dp[j]+cube(Math.abs(a[middle]-x[j]))+cube(y[j]); if(value1>=value2)pass=middle; else fail=middle; } return pass; } long[] solveMongeDP(long[]a,long[]x,long[]y){ int n=a.length; long[]dp=new long[n+1]; Arrays.fill(dp,Long.MAX_VALUE); dp[0]=0; int[]deq=new int[n+1]; int[]rev=new int[n+1]; int s=0,t=0; for(int i=0;i