CF474B.Worms

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 a__i worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to _a_1, worms in second pile are labeled with numbers _a_1 + 1 to _a_1 + _a_2 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.

现在是鼹鼠的午餐时间。他的朋友土拨鼠为他准备了一个有趣的午餐游戏。

土拨鼠为鼹鼠带来了 $ n $ 堆有序排列的虫子,其中第 $ i $ 堆包含 $ a_i $ 条虫子。他用连续的整数为所有这些虫子编号:第一堆虫子编号为 $ 1 $ 到 $ a_1 $,第二堆虫子编号为 $ a_1 + 1 $ 到 $ a_1 + a_2 $,依此类推。参见示例以获得更清晰的理解。

鼹鼠无法吃掉全部虫子(土拨鼠带了很多),而且众所周知,鼹鼠是盲的,因此土拨鼠会告诉他哪些编号的虫子最鲜美多汁。但土拨鼠只会在鼹鼠正确说出该虫子位于哪一堆时,才把虫子给他。

可怜的鼹鼠向你求助。对于土拨鼠提到的每一条鲜美多汁的虫子,请告诉鼹鼠它所在的正确堆号。

输入格式

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

The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 103, _a_1 + _a_2 + ... + a__n ≤ 106), where a__i 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 _q_1, _q_2, ..., q__m (1 ≤ q__i ≤ _a_1 + _a_2 + ... + a__n), the labels of the juicy worms.

第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5),表示堆的数量。

第二行包含 nn 个整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n(1≤ai≤1031 \leq a_i \leq 10^3,且 a1+a2+⋯+an≤106a_1 + a_2 + \dots + a_n \leq 10^6),其中 aia_i 表示第 ii 堆中的虫子数量。

第三行包含一个整数 mm(1≤m≤1051 \leq m \leq 10^5),表示 Marmot 所说的多汁虫子的数量。

第四行包含 mm 个整数 q1, q2, …, qmq_1,\,q_2,\,\dots,\,q_m(1≤qi≤a1+a2+⋯+an1 \leq q_i \leq a_1 + a_2 + \dots + a_n),表示这些多汁虫子的编号。

输出格式

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 q__i is.

向标准输出打印 m 行。第 i 行应包含一个整数,表示编号为 q__i 的蠕虫所在的堆的编号。

输入输出样例

  • 输入#1

    5
    2 7 3 4 9
    3
    1 25 11

    输出#1

    1
    5
    3

说明/提示

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.

对于样例输入:

  • 标号为 [1, 2] 的蠕虫在第一堆中。
  • 标号为 [3, 9] 的蠕虫在第二堆中。
  • 标号为 [10, 12] 的蠕虫在第三堆中。
  • 标号为 [13, 16] 的蠕虫在第四堆中。
  • 标号为 [17, 25] 的蠕虫在第五堆中。

输入解题思路,AI测评打分。不知道怎么写?

首页