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

#include <bits/stdc++.h>
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define pd(n) printf("%d\n", (n))
#define pdd(n,m) printf("%d %d\n", n, m)
#define pld(n) printf("%lld\n", n)
#define pldd(n,m) printf("%lld %lld\n", n, m)
#define pds(n) printf("%d ", (n))
#define plds(n) printf("%lld ", n)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ps(str) printf("%s\n",str)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define mst(a,n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef unsigned long long ULL;
typedef long long LL;
const int maxn = 5e5 + 10;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
int t, x, y, n;
double r[110];
int main() {
	sd(t);
	while (t--) {
		sddd(x, y, n);
		rep(i, 0, n)
			sf(r[i]);
		sort(r, r + n, greater<double>());
		int i = 0, cnt = 0, ans = 1;
		double s = 0;
		while (1) {
			if (r[i] * 2 < y||i==n) {
				ans = 0;
				break;
			}
			s += sqrt(4 * r[i] * r[i] - y * y);
			++cnt;
			++i;
			if (s >= x)
				break;
		}
		if (ans)
			pd(cnt);
		else
			pd(-1);
	}
}