CodeForces 474B (TAG usage), codeforces474b

Source: Internet
Author: User

CodeForces 474B (TAG usage), codeforces474b
CodeForces 474B

Time Limit:1000 MSMemory Limit:262144KB64bit IO Format:% I64d & % I64u

Description

It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.

Marmot brought MoleNOrdered piles of worms such thatI-Th pile containsAiWorms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1A1, worms in second pile are labeled with numbersA1 second + second 1A1 worker + workerA2 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 integerN(1 digit ≤ DigitNLimit ≤ limit 105), the number of piles.

The second line containsNIntegersA1, bytes,A2, middle..., middle ,...,An(1 digit ≤ DigitAiLimit ≤ limit 103,A1 worker + workerA2 cores + cores... cores + CoresAnLimit ≤ limit 106), whereAiIs the number of worms inI-Th pile.

The third line contains single integerM(1 digit ≤ DigitMLimit ≤0000105), the number of juicy worms said by Marmot.

The fourth line containsMIntegersQ1, bytes,Q2, middle..., middle ,...,Qm(1 digit ≤ DigitQiLimit ≤ limitA1 worker + workerA2 cores + cores... cores + CoresAn), The labels of the juicy worms.

Output

PrintMLines to the standard output.I-Th line shoshould contain an integer, representing the number of the pile where the worm labeled with the numberQiIs.

Sample Input

Input

5
2 7 3 4 9
3
1 25 11

Output

1
5
3

Hint

For the sampleinput:

  • 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 same th pile.
  • Question: If this question is hard to fully understand, you can combine the input case, that is, the data in the first row is five rows, and the data in the second row is, 9, the number of the first row is 2, the second row is 7, and so on. To the second row, the data in the third row is the number of numbers to be judged, the fourth row of data is the number to be judged and the number of rows to be determined.
  • As follows:
  • 1 2
  • 3 4 5 6 7 8 9
  • 10 11 12
  • 13 14 15 16 17
  • 18 19 20 21 22 23 24 25
  • To determine the number of rows in the case of, you can first create an array, sort them in sequence, mark each row, mark the first row as 1, and so on, when a q is input, output a [q] to obtain the number of rows.
  • When marking, you must pay attention to its range. After marking a row, you must add + 1 to reach the second row.
  • # Include <iostream>

  • Using namespace std;

  • Int a [100];
    Int main ()
    {
    Int q, s, n, I, t, tot, f = 1;
    While (cin> n)
    {
    Tot = 1;
    For (int j = 1; j <= n; j ++)
    {
    Cin> t;
    For (I = tot; I <t + tot; I ++)
    A [I] = f;
    F ++;// Mark each time, f ++, to reach the next line
    Tot = I;
    }

    Cin> q;

    For (I = 1; I <= q; I ++)
    {
    Cin> s;
    Cout <a [s] <endl; // enter the number q and output a [q]. The row where q is located is obtained.

    }
    }

    Return 0;
    }
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.