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: 1144kB
Author: 2018212212175
In contest: 1292

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
bool cmp(const double &a,const double &b){
	return a>b;
}
double sum[1000];
int main(){
	int t,x,y,n,flag,tans;
	double ans,len;
	scanf("%d",&t);
	while(t--){
		flag=0;ans=0,tans=0;
		scanf("%d%d%d",&x,&y,&n);
		for(int i=1;i<=n;i++){
			scanf("%lf",&sum[i]);
		}
		sort(sum+1,sum+n+1,cmp);
		for(int i=1;i<=n;i++){
			if(2*sum[i]<=y) {
				break;
			}
			tans++;
			ans+=sqrt(sum[i]*sum[i]-1.0*y*y/4)*2;
			if(ans>=x) {
				flag=1;
				break;
			}
		}
		if(flag) {
			printf("%d\n",tans);
		}
		else printf("-1\n"); 
	}
}