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. dotnetcore3.1 WPF 实现多语言

    dotnetcore3.1 WPF 实现多语言 Intro 最近把 DbTool 从 WinForm 迁移到了 WPF,并更新到了 dotnet core 3.1,并实现了基于 Microsoft.E ...

  2. springcloud vue.js 前后分离 微服务 分布式 activiti工作流 集成代码生成器 shiro权限

    1.代码生成器: [正反双向](单表.主表.明细表.树形表,快速开发利器)freemaker模版技术 ,0个代码不用写,生成完整的一个模块,带页面.建表sql脚本.处理类.service等完整模块2. ...

  3. Verilog HDL学习_1:分频器/PWM的实现

    (一)参考学习资料 (二)实际操作 1. 相关变量计算:   First Initial Second Initial Upper case H X ASCII (Dec) 72 88 Lengths ...

  4. 深入源码分析SpringMVC执行过程

    本文主要讲解 SpringMVC 执行过程,并针对相关源码进行解析. 首先,让我们从 Spring MVC 的四大组件:前端控制器(DispatcherServlet).处理器映射器(HandlerM ...

  5. Android.mk文件LOCAL_SDK_VERSION选项

    Api分类 internal api 翻译为内部API,理解为供sdk内部使用的API. 这类接口最初打算就是不对外公开的,有点private的意思. hide api 在源码中看到使用@hide 标 ...

  6. iOS 开发技术栈与进阶

    最近有一些开发朋友问我应该怎样提升自己的能力,回想起来做了这么久 iOS 开发,我也有过那种“让我做一个功能实现个需求我会做,但接下来怎样提高我不知道.”的时期,这里尝试列一下 iOS 开发的相关技术 ...

  7. QuantLib 金融计算——自己动手封装 Python 接口(2)

    目录 QuantLib 金融计算--自己动手封装 Python 接口(2) 概述 如何封装一项复杂功能? 寻找最小功能集合的策略 实践 估计期限结构参数 修改官方接口文件 下一步的计划 QuantLi ...

  8. mac 电脑画图软件相关

    sketchbook 免费但是不太好用 sketch, https://www.newasp.net/soft/327640.html 注意:安装前,请开启任何来源.OS X 10.12 及以上版本请 ...

  9. SSL证书基础知识

    公司要为一个英国的客户提供由HTTP升级到HTTPS的服务,于是接触查询并学习了相关的SSL证书方面的内容,并整理了一翻. I.SSL证书说明 SSL 证书按大类一般可分为 DV SSL .OV SS ...

  10. TChart-图表编辑器的测试

    最近不知怎么的,想研究一下图表.先上效果图: 功能代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Class ...