#include <algorithm>
#include <iostream>
using namespace std;
int main() {
long long n, L, v, q;
long long a[200005], b[200005];
cin >> n >> L >> v;
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
cin >> q;
sort(a, a + n, greater<long long>());
b[0] = a[0];
for (long long i = 1; i < n; i++) {
b[i] = b[i - 1] + a[i] + L;
}
for (long long i = 0; i < q; i++) {
long long temp;
cin >> temp;
temp *= v;
if (temp > L) {
cout << 0 << endl;
continue;
}
if (b[n - 1] <= temp) {
cout << -1 << endl;
} else {
cout << std::upper_bound(b, b + n, temp) - b << endl;
}
}
return 0;
}
编译通过
运行时卡住,不能输入数据