Start: Jul, 03, 2019 08:38:00
2019年度暑期短学期第七天 助教场
End: Jul, 04, 2019 23:00:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 4ms
Memory: 1772kB
Author: 2017212212237
In contest: 1292

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;

const int maxn = 1e2 + 10;

double a[maxn];
bool cmp(double x,double y)
{
    return x > y;
}
int main()
{
   int t;
   scanf("%d",&t);
   while(t--)
   {
       double x,y;
       int n;
       scanf("%lf %lf %d",&x,&y,&n);
       for(int i=0;i<n;i++)
       {
           scanf("%lf",&a[i]);
           if(a[i] <= y/2)
               a[i] = 0;
           else
            a[i] = 2 * sqrt(a[i] * a[i] - (y / 2)*(y / 2));
       }
       sort(a,a+n,cmp);
//       for(int i=0;i<n;i++)
//           printf("%lf ",a[i]);
       int ans = 0;
       for(int i=0;i<n;i++)
       {
           if(x > 0)
           {
               ans++;
               x -= a[i];
           }
           else
               break;
       }
       if(x <= 0)
        printf("%d\n",ans);
       else
           puts("-1");
   }
}