import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] nums = new int[n]; for(int i = 0; i < n; i++) { nums[i] = in.nextInt(); } in.close(); Arrays.sort(nums); int sum = nums[0]; int result = 1; for(int i = 1; i < n; i++) { if(nums[i] <= sum) { result++; } else { result = 1; } sum += nums[i]; } System.out.println(result); } }
自测了一些都通过了,跑的都是通过0,想不出问题,郁闷🙄
全部评论
(3) 回帖