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.

Examples
input
5
2 7 3 4 9
3
1 25 11
output
1
5
3
Note

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.
 #include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
int main()
{
int n,m;
int ans[],i,j=,k,num;
scanf("%d",&n);
for(i=;i<=n;i++){
scanf("%d",&num);
for(k=;k<num;k++){
ans[j++]=i;
}
}
scanf("%d",&m);
for(i=;i<m;i++){
scanf("%d",&num);
printf("%d\n",ans[num]);
}
return ;
}

Codeforces 474B. Worms的更多相关文章

  1. Codeforces 474B Worms 二分法(水

    主题链接:http://codeforces.com/contest/474/problem/B #include <iostream> #include <cmath> #i ...

  2. CodeForces 474B Worms (水题,二分)

    题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc+ ...

  3. CodeForces 474B(标记用法)

    CodeForces 474B Time Limit:1000MS Memory Limit:262144KB   64bit IO Format:%I64d & %I64u Descript ...

  4. CodeForces 474B E(Contest #1)

    题意: 给你一个数n,代表n段区间,接下来有n个数(a1,a2,...an)代表每段区间的长度,第一段区间为[1,a1],第二段区间为[a1+1,a1+a2],...第i段区间为[ai-1+1,ai- ...

  5. Worms

    474B Worms time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  6. Codeforces Round #271 (Div. 2)-B. Worms

    http://codeforces.com/problemset/problem/474/B B. Worms time limit per test 1 second memory limit pe ...

  7. Codeforces 271 Div 2 B. Worms

    题目链接:http://codeforces.com/contest/474/problem/B 解题报告:给你n个堆,第i个堆有ai个物品,物品的编号从1开始,第一堆的编号从1到a1,第二堆编号从a ...

  8. Codeforces Round #474-B(贪心)

    一.题目链接 http://codeforces.com/contest/960/problem/B 二.题意 给定三个数字$N, k1, k2$,接下来给出两组数$a[]$和$b[]$,每组数$N$ ...

  9. B. Worms Codeforces Round #271 (div2)

    B. Worms time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

随机推荐

  1. Python——格式输出,基本数据

    一.问题点(有待解决) 1.Python中只有浮点数,20和20.0是否一样? from decimal import Decimal  a = Decimal('1.3') round() 参考文章 ...

  2. 学Python必背的初级单词,你都背了吗?

    今天给大家分享一些学习Python必须认识的英文单词,同时也是学习编程都必须会的单词,新手赶快学起来!有点长耐心看完. 小编推荐一个学Python的学习裙:九三七六六七 五零九,无论你是大牛还是小白, ...

  3. JS中new的实现原理及重写

    提到new,肯定会和类和实例联系起来,如: function Func() { let x = 100; this.num = x + } let f = new Func(); 上面的代码,我们首先 ...

  4. ​Microchip SPI串行SRAM和NVSRAM器件

    Microchip的SRAM和NVSRAM系列(SPI串行SRAM和NVSRAM设备)提供了一种轻松添加外部RAM的方式,且具有以下特性功能 特性低功耗CMOS技术:4μA最大待机电流 标准4引脚SP ...

  5. hadoop完全分布式部署

    1.我们先看看一台节点的hdfs的信息:(已经安装了hadoop的虚拟机:安装hadoophttps://www.cnblogs.com/lyx666/p/12335360.html) start-d ...

  6. IIS网站部署配置

    1.配置Session State

  7. Kubernetes 部署 Nebula 图数据库集群

    Kubernetes 是什么 Kubernetes 是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes 的目标是让部署容器化的应用简单并且高效,Kubernetes 提供了应 ...

  8. .net对象与IntPtr"互转"

    写于2015-1-29 16:17 由qq空间转过来,格式有点乱 "互转"这里其实只是GC分配的一个IntPtr,通过这个IntPtr引用操作而真正的托管对象与非托管对象的互转应使 ...

  9. C# WPF可拖拽的TabControl

    微信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏. C# WPF可拖拽的TabControl 阅读导航 本文背景 代码实现 本文参考 源码 1. ...

  10. TensorFlow安装-(Ubuntu18.04.3 & Anaconda3)

    1.背景 使用ubuntu18.04.3安装Anaconda3之后使用网上教程安装tensorflow失败,踩了多个坑,特此总结经验 附官方教程:https://tensorflow.google.c ...