#P802. Worms ( 蠕蟲 )
Worms ( 蠕蟲 )
題目描述
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.
現在是 Mole 的午餐時間。 他的朋友土撥鼠為他準備了一場精彩的午餐比賽。
Marmot 給 Mole 帶來了 n 堆蠕蟲,使得第 i 堆包含 ai 條蠕蟲。 他用連續的整數標記所有這些蠕蟲:第一堆中的蠕蟲被標記為數字 1 到 a1,第二堆中的蠕蟲被標記為數字 a1 + 1 到 a1 + a2 等等。 請參閱示例以獲得更好的理解。
鼴鼠不能吃掉所有的蟲子(土撥鼠帶來了很多),而且眾所周知,鼴鼠是盲人,所以土撥鼠告訴他最好吃的多汁蟲子的標籤。 如果鼴鼠正確地說出這條蠕蟲包含在哪一堆中,土撥鼠只會給鼴鼠一條蠕蟲。
可憐的鼴鼠向你尋求幫助。 對於 Marmot 所說的所有多汁蠕蟲,請告訴 Mole 正確答案。
輸入格式
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.
第一行包含一個整數 n (1 ≤ n ≤ 105),即堆的數量。
第二行包含 n 個整數 a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106),其中 ai 是第 i 堆中的蠕蟲數量。
第三行包含單個整數 m (1 ≤ m ≤ 105),土撥鼠所說的多汁蠕蟲的數量。
第四行包含 m 個整數 q1, q2, ..., qm (1 ≤ qi ≤ a1 + a2 + ... + an),多汁蠕蟲的標籤。
輸出格式
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.
將 m 行打印到標準輸出。 第 i 行應包含一個整數,表示標有數字 qi 的蠕蟲所在的堆的編號。
Samples
5
2 7 3 4 9
3
1 25 11
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] 標籤的蠕蟲在第五堆中。
原始資料
- Zero1 題號:
a802 - Hydro 題號:
Z0802 - Locale:
zh_TW - Display:
practice