import java.net.NetworkInterface; import java.util.*; public class Main {public static int upper_bound(long[] arr, long key) { int len = arr.length; int lo = 0; int hi = len-1; int mid = (lo + hi)/2; while (true) { long cmp = arr[mid]-key; if (cmp == 0 || cmp < 0) { lo = mid+1; if (hi < lo) return mid0){ int x = upper_bound(aaa, sa)-1; if(x<0) x=n-3; sa-=aaa[x]; ans++; } System.out.println(ans); } }