来个骚的 import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { //O(nlogn) Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); int a[]=new int[n]; for (int i = 0; i < a.length; i++) { a[i]=scanner.nextInt(); } int m=scanner.nextInt(); int q[]=new int[m]; for (int i = 0; i < q.length; i++) { q[i]=scanner.nextInt(); } scanner.close(); int count[]=new int[n]; count[0]=a[0]; for (int i = 1; i < count.length; i++) { count[i]=count[i-1]+a[i]; } for (int i = 0; i < q.length; i++) { int s=Arrays.binarySearch(count, q[i]); if(s>0) { System.out.println(s+1); }else { System.out.println(Math.abs(s)); } } } }