Food Lines

View as PDF

Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 N such food lines in the city of Lachtin, the ith of which has a_i people in it. M 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.


1\leq N\leq 100
1 \leq a_i \leq 100\space for i in 1,2\ldots N
1 \leq M \leq 100

Input Specification

The first line contains two positive integers, N and M.
The second line contains N positive integers,a_1,a_2,\ldots,a_N

Output Specification

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

Sample Input

5 3
2 2 3 3 3

Sample Output



There are no comments at the moment.