喷水装置 -------

 

 这一道题 是有毛病的 ,  宽度为 2 长度为 20  ,  按照AC的答案来说 , 是只要长度能覆盖 20 就行 .. 但是 事实不是这样的  .  下面附上AC 代码 

 1 #include<stdio.h>
 2 #include<algorithm>
 3 using namespace std;
 4 bool cmp(double a,double b)
 5 {
 6     return a>b;
 7 }
 8 int main()
 9 {
10     int t;
11     double a[606];
12     scanf("%d",&t);
13     while(t--)
14     {
15         int n;
16         scanf("%d",&n);
17         for(int i=0;i<n;i++)
18             scanf("%lf",&a[i]);
19         sort(a,a+n,cmp);
20         int l=0,count1=0;
21         for(int i=0;i<n;i++)
22         {
23             l+=2*a[i];
24             count1++;
25             if(l>20)
26             {
27                 printf("%d
",count1);
28                 break;
29             }
30         }
31     }
32 }

 

 

原文地址:https://www.cnblogs.com/A-FM/p/5405988.html