这道题貌似怎么写都可以吧= =,我先读入询问然后从小到大处理就行了= =
PS:水水题真的好!无!聊!但是好!欢!乐!
CODE:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 50010
int b[maxn],q[maxn],id[maxn],ans[maxn];
bool cmp(int x,int y){return q[x]<q[y];}
int main(){
int n,Q;
scanf("%d%d",&n,&Q);
for (int i=1;i<=n;i++) scanf("%d",b+i);
for (int i=1;i<=Q;i++) scanf("%d",q+i);
for (int i=1;i<=Q;i++) id[i]=i;
sort(id+1,id+1+Q,cmp);
int h=1,t=0;
for (int i=1;i<=n;i++) {
t+=b[i];
while (q[id[h]]<t&&h<=Q) ans[id[h++]]=i;
}
for (int i=1;i<=Q;i++) printf("%d\n",ans[i]);
return 0;
}