import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } final long MOD=(long)1e9+7; boolean f(long[] A,int[] x,long[] w,long c) { int N=A.length,M=x.length; boolean ret=true; if(c==0) { long sum=Arrays.stream(w).sum(); return sum1) { long middle=(ok+ng)/2; if(f(A,x,w,middle)) { ok=middle; }else { ng=middle; } } System.out.println(ok==INF?-1:ok); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }