显示代码纯文本
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=200005;
bool cmp(int a,int b){return a>b;}
int n,l,v,q;
int a[MAXN];
long long s[MAXN];
int main(){
freopen("noi_online_endless.in","r",stdin);
freopen("noi_online_endless.out","w",stdout);
scanf("%d%d%d",&n,&l,&v);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n,cmp);
s[0]=l;
for(int i=1;i<=n;i++)
s[i]=s[i-1]+a[i];
scanf("%d",&q);
while(q--){
long long t;
scanf("%lld",&t);
t*=v;
int i=0;
while(t>=s[i]){
i++;
}
if(i<=n)printf("%d\n",i);
else printf("-1\n");
}
return 0;
}