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: 5772kB
Author: 2018212212317
In contest: 1292

#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
const int maxn = 1010;
const int inf = 0x3f3f3f3f;
const int modu = 1e9+7;
const double PI = 3.1415926;
int n,m,k,t,sum,ans,minn;
int x,y;
double l,r,q;
int a[maxn][maxn];
double b[maxn];
map<string,int> mp; 
string s[maxn];
bool cmp(double a ,double b){
	return a>b;
}
int main(){
	cin>>t;
	while(t--){
		ans=0;
		cin>>n>>m>>k;
		for(int i=0;i<k;i++){
			cin>>b[i];
			b[i]=b[i]>m*1.0/2?sqrt(b[i]*b[i]-(double)m*m/4.0):0.0;
		}
		sort(b,b+k,cmp);
		l=n*1.0;
		for(int i=0;i<k;i++){
			if(b[i]==0.0) break;
			l-=2*b[i];
			ans++;
			if(l<=0) break;
		}
		if(l>0) cout<<"-1"<<endl;
		else cout<<ans<<endl;
	}
	
}