Worms

Description

It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.

Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers a1 + 1 to a1 + a2 and so on. See the example for a better understanding.

Mole can't eat all the worms (Marmot brought a lot) and, as we all know, Mole is blind, so Marmot tells him the labels of the best juicy worms. Marmot will only give Mole a worm if Mole says correctly in which pile this worm is contained.

Poor Mole asks for your help. For all juicy worms said by Marmot, tell Mole the correct answers.

Input

The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile.

The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot.

The fourth line contains m integers q1, q2, ..., qm (1 ≤ qi ≤ a1 + a2 + ... + an), the labels of the juicy worms.

Output

Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.

Sample Input

Input
5
2 7 3 4 9
3
1 25 11
Output
1
5
3

Hint

For the sample input:

  • The worms with labels from [1, 2] are in the first pile.
  • The worms with labels from [3, 9] are in the second pile.
  • The worms with labels from [10, 12] are in the third pile.
  • The worms with labels from [13, 16] are in the fourth pile.
  • The worms with labels from [17, 25] are in the fifth pile.


说好的 105,总RE,开到106才AC,醉了


#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int num[1000010];

int main(){
    int n,i,t,m,k,j,number,pile;
    while(cin>>n){
        number=1;
        pile=1;
        for(i=0;i<n;i++){
            cin>>t;
            for(j=number;j<t+number;j++){
                num[j]=pile;
            }
            number=j;//number=t+number;
            pile++;
        }
        cin>>m;
        for(i=0;i<m;i++){
            cin>>k;
            cout<<num[k]<<endl;
        }
    }
    return 0;
}


资源下载链接为: https://pan.quark.cn/s/f1ead55c4354 以下标题“H5页面模板源码,很不错的例子”暗示了我们讨论的主题是关于HTML5页面模板的源代码。HTML5是现代网页开发的核心技术,它提供了丰富的功能和元素,让开发者能够构建出更具交互性、动态性和响应式的网页。“很不错的例子”表明这些源码不仅具有实用性,还具备一定的教学意义,既可以作为项目开发的直接素材,也能供学习参考。 在描述“H5页面模板源码,非常酷炫的HTML5模板,可以直接使用,也可以参考学习”中,“非常酷炫”意味着这些模板可能融合了诸多高级特性,例如动画效果、媒体元素的运用以及响应式设计等,这些都是HTML5技术的优势所在。可以直接使用表明用户无需从零开始编写代码,能迅速搭建出吸引人的网页。同时,这些模板也适合学习,用户通过查看源代码可以了解特定设计和功能的实现方式,从而提升自身的HTML5开发能力。 标签“H5 手机网页 H5源代码 手机html”进一步明确了主题。“H5”是HTML5的简称,“手机网页”和“手机html”则强调这些模板是针对移动设备优化的。在如今移动优先的时代,适应各种屏幕尺寸和触摸操作的网页设计极为重要。这表明这些源码很可能是响应式的,能够根据设备自动调整布局,以适配手机、平板电脑等多种设备。 从“压缩包文件的文件名称列表”来看,虽然无法直接从文件名得知具体源码内容,但可以推测这些文件可能包含多种HTML5模板示例。“不错的样子.txt”可能是一个介绍或说明文件,对模板进行简要描述或提供使用指南。而“1-30”这样的命名方式可能意味着有30个不同的模板实例,每个模板对应一个独立文件,涵盖多种设计风格和功能,为学习和实践提供了全面的平台。 总的来说,这个资源集合为HTML5开发者或初学者提供了一套实用且酷炫的移动网页模板源代码。这些模板既可以直接应用于项目
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值