NYOJ之喷水装置(一)
----------------------------------------------------------------------------
AC代码:
1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static void main(String[] args) { 7 8 Scanner sc=new Scanner(System.in); 9 int k=sc.nextInt(); 10 while(k-->0){ 11 int n=sc.nextInt(); 12 double x[]=new double[n]; 13 for(int i=0;i<x.length;i++){ 14 x[i]=sc.nextDouble(); 15 } 16 17 Arrays.sort(x); 18 int ans=0; 19 double c=20; 20 for(int i=x.length-1;i>=0 && c>=0;i--){ 21 c-=x[i]*2; 22 ans++; 23 } 24 System.out.println(ans); 25 } 26 27 } 28 29 }