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: 1768kB
Author: 2018212212125
In contest: 1292

#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<iostream>
#define ll long long 
using namespace std;
const int maxn = 100 + 10;
const int inf = 0x3f3f3f3f;
int  n, t;
double x, y;
double a[maxn];
int main()
{
	scanf("%d", &t);
	while (t--) 
	{
		scanf("%lf %lf %d", &x, &y, &n);
		for (int i = 1; i <= n; ++i)
			scanf("%lf", &a[i]);
		sort(a + 1, a + 1 + n);
		reverse(a + 1, a + 1 + n);
		double kk = y * 1.0 / 2.0;
		int i;
		double dis = 0;
		for (i = 1; i <= n; ++i) 
		{
			if (a[i] > kk)
				dis += 2.0*sqrt(a[i] * a[i] - kk * kk);
			else
				break;
			if (dis >= x)
				break;
		}
		if (dis<x)printf("-1\n");
		else printf("%d\n", i);


	}
}