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. 【GET TIPS】Chrome所见即所得的截图技巧

    精简的前言: 对,我就是想说下事情的来龙去脉.您要不想听,就把耳朵捂起来23333. 想截个新冠肺炎病毒,全国确诊人数今日增长的图,以确定非湖北地区不再明显增长. 但由于网页需要的内容分布在两页,需要 ...

  2. Swift 枚举-从汇编角度看枚举内存结构

    一.基本使用 先看枚举的几种使用(暂不要问,看看是否都能看懂,待会会逐一讲解) 1.操作一 简单使用 //第一种方式 enum Direction { case east case west case ...

  3. C#设计模式学习笔记:(16)观察者模式

    本笔记摘抄自:https://www.cnblogs.com/PatrickLiu/p/7928521.html,记录一下学习过程以备后续查用. 一.引言 今天我们要讲行为型设计模式的第四个模式--观 ...

  4. C# 获取鼠标在屏幕上的位置

    获取鼠标位置及鼠标单击了哪个按键.private void GetMousePoint() {     Point ms = Control.MousePosition;     this.label ...

  5. Windwos应急响应和系统加固(1)——Windwos操作系统版本介绍

    Windwos操作系统版本介绍 1. Micorsoft  Windows XP  ·Microsoft官方发布时间以及终止提供服务时间:2001.10.25-2014.4.8   产生漏洞:MS08 ...

  6. 万科A顺利出局,布局一心堂

    万科的这两日的走势还不错,今日冲高回落,顺利出局. 那么有选中了一只 股票    一心堂 资金量W    12 建仓价格    22.2 加仓系数    1.5 加仓间隔    1.50% 总盈利比  ...

  7. .NET CORE(C#) WPF 值得推荐的动画菜单设计

    微信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏. .NET CORE(C#) WPF 值得推荐的动画菜单设计 阅读导航 本文背景 代码实现 本文 ...

  8. mybatis配置---> mybatisConfig.xml 配置加接数据源

    mybatisConfig.xml 配置主要作用是连接数据源配置的前提是在完成mybatis的jar包基础之上进行的同时要确保数据用户名和密码是否正确 一:密码写在 mybatisConfig.xml ...

  9. PHP0019:PHP 图像验证码 、图像水印效果 、 生成缩约图

  10. sql server通过临时存储过程实现使用参数添加文件组脚本复用

    create procedure #pr_CreateFileGroup @dbname nvarchar(max), @filegroupname nvarchar(max) as begin /* ...