Under construction

Still being built. Things may change

Distributing Ballot Boxes

Time limit3sMemory limit128 MB

Summary
Given city populations and a fixed total number of ballot boxes (each city gets at least one), find the assignment minimizing the maximum people per box, via binary search over the answer.
Level

Medium5 of 10

Topics
Binary search, Greedy
Solved
No attempts yet

Problem

Today, besides SWERC'11, another important event is taking place in Spain that rivals it in importance: the General Elections. Every resident of the country aged 18 or over is asked to vote in order to choose representatives for the Congress of Deputies and the Senate. Do not worry that all the judges will suddenly abandon their supervising duties: voting is not compulsory.

The administration has a number of ballot boxes left over from past elections. Unfortunately, the person in charge of distributing the boxes among the cities was dismissed a few months ago due to budget cuts. As a consequence, the current assignment of boxes to cities, and of the people who must vote in each of them, is arguably far from optimal. Your task is to show how efficiently this could have been done.

The only rule when assigning ballot boxes to cities is that every city must receive at least one box. Each person votes in the box to which they have been assigned. Your goal is to find a distribution that minimizes the maximum number of people assigned to vote in a single box.

In the first sample case, two boxes go to the first city and the rest to the second, and exactly 100000 people are assigned to each of the (huge!) boxes in the most efficient distribution. In the second sample case, the cities receive 1, 2, 2, and 1 ballot boxes, and 1700 people from the third city are called to vote in each of that city's two boxes, making them the most crowded boxes of all in the optimal assignment.

Input

The input consists of several test cases. The first line of each test case contains two integers NN (1≤N≤5000001 \le N \le 500000), the number of cities, and BB (N≤B≤2000000N \le B \le 2000000), the number of ballot boxes. Each of the following NN lines contains an integer aia_i (1≤ai≤50000001 \le a_i \le 5000000), the population of the ii-th city.

A single blank line follows each test case. The last line of the input contains -1 -1 and must not be processed.

Output

For each test case, output a single integer: the maximum number of people assigned to one box in the most efficient assignment.

Examples1

  1. Example 1

    Input
    2 7
    200000
    500000
    
    4 6
    120
    2680
    3400
    200
    
    -1 -1
    
    Expected output
    100000
    1700