## LKP '18 Contest 2 P1 - Food Lines

View as PDF

Points: 3
Time limit: 3.0s
Memory limit: 64M

Author:
Problem type

After many years of continuous warfare, the country of Collea was left in shambles. This has caused food shortages and famines all across the country. In an attempt to distribute the little food that was produced and prevent food hoarding, the Collean government limited the amount of food that any one person can buy. Soon, Collean citizens are forced to wait in long lines in order to obtain the food they needed. There are currently such food lines in the city of Lachtin, the th of which has people in it. people are going to enter one of the lines in the next hour, where they each enter the shortest line they see. Since Phreia plans to enter the line, she wants to know the length of the line that each person decides to join.

for in

#### Input Specification

The first line contains two positive integers, and .
The second line contains positive integers, .

#### Output Specification

Print lines, the th of which being the length of the line that the th person joined.

#### Sample Input

5 3
2 2 3 3 3

#### Sample Output

2
2
3

• commented on Aug. 13, 2022, 3:06 p.m.

the second line in input indicates the number of people in each line. Thx.

• commented on Oct. 11, 2021, 6:28 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on May 30, 2021, 4:01 p.m.

Solution:

• Create a helper function for calculating the shortest line using a simple for-loop.
• Loop over the number of new people m. Find the shortest line. Print it. Then, increment that short line.