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: 79896kB
Author: 2018212212127
In contest: 1292

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e7+100;
double a[maxn];
struct rule{
	bool operator()(const double &a1,const double &a2){
		return a1>a2;
	}
};
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		double x,y;
		int n,tot=0;
		scanf("%lf %lf %d",&x,&y,&n);
		for(int i=0;i<n;i++){
			double k;
			scanf("%lf",&k);
			double f=4*k*k-y*y;
			if(f<0) a[i]=0;
			else a[i]=sqrt(f);
		}
		sort(a,a+n,rule());
		for(int i=0;i<n;i++){
			x-=a[i];
			tot++;
			if(x<=0) break;
		}
		if(x>0) printf("-1\n");
		else printf("%d\n",tot);
	}
}