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: 6ms
Memory: 1768kB
Author: 2017212212207
In contest: 1292

#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int T;
	int x,y,n,i,cnt,flag;
	double r[100],sum;
	scanf("%d",&T);
	while(T--){
		cnt=0;flag=1;
		scanf("%d%d%d",&x,&y,&n);
		for(i=0;i<n;i++){
			scanf("%lf",&r[i]);
		}
		sort(r,r+n);
		sum=0;i=n-1;
		while(1){
			if(2*r[i]<=y){flag=0;break;}
			sum+=sqrt(4*r[i]*r[i]-y*y);
			cnt++;
			i--;
			if(sum-x>=0){break;}
			if(i==-1){flag=0;break;}
		}if(flag){printf("%d\n",cnt);}
		else{printf("-1\n");}
	}
}