CF474B Worms
题目描述
现在是鼹鼠的午餐时间,他的好友土拨鼠,为他准备了一个游戏。
土拨鼠带来了成堆的蚯蚓,使第 $i$ 堆中有 $a_i$ 条蚯蚓。它用连续整数给所有这些蚯蚓打标签:第一堆蚯蚓用数字 $1$ 到 $a_1$ 标记,第二堆蚯蚓用数字 $a_1 + 1$ 到 $a_1 + a_2$ 标记 ...... 以此类推。
鼹鼠吃不掉所有的蚯蚓 (土拨鼠带来了一大堆) ,而且我们都知道,鼹鼠是是看不见东西的,所以土拨鼠会告诉鼹鼠多汁蚯蚓的标签。如果鼹鼠正确地说出这个蚯蚓在哪个堆里,土拨鼠就会给鼹鼠一条蚯蚓。
可怜的鼹鼠向你求助,希望你能告诉鼹鼠正确的答案。
输入格式
输入共有4行。
第一行包含一个整数 $n$ $(1 \le n \le 10^5)$,即土拨鼠带来的蚯蚓堆数。
第二行包含 $n$ 个整数 :$a_1$ $a_2$ ... $(1 \le a_i \le 10^3 ,a1 + a2 +... + a_n \le 10^6)$, $a_i$ 表示在第 $i$ 个堆里蚯蚓的数量。
第三行包含一个整数 $m$ $(1 \le m \le 10^5)$ ,代表土拨鼠所告诉鼹鼠的多汁蚯蚓的数量。
第四行包含 $m$ 个整数 $q_1$ , $q_2$ ,... , $q_m$ $(1 \le q_i \le a_1 + a_2 +…+a_n)$ , 表示土拨鼠所告诉鼹鼠的多汁蚯蚓的标签。
输出格式
输出共有 $m$ 行 。第 $i$ 行包含一个整数,表示标签为 $q_i$ 的蚯蚓所在的蚯蚓堆的编号。
说明/提示
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.