Result: Accepted
Time: 3ms
Memory: 1772kB
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#define lowbit(x) (x&(-x))
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
using namespace std;
const int maxn = 110;
double r[maxn];
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
double x, y;
int n;
scanf("%lf%lf%d", &x, &y, &n);
for (int i = 0; i < n; ++i)
scanf("%lf", i + r);
sort(r, r + n, greater<double>());
int ans = 0;
for (int i = 0; i < n && x>0 && y / 2 < r[i]; ++i, ++ans)
{
x -= 2 * sqrt(r[i] * r[i] - (y / 2) * (y / 2));
}
if (x > 0)
puts("-1");
else
printf("%d\n", ans);
}
// system("pause");
}