A Discrete Mathematics professor has a class of
N students. Frustrated with their lack of discipline, he decides to cancel class if fewer than
K students are present when class starts.
Given the arrival time of each student, determine if the class is canceled.
First take in
T, the number of cases.
For each case, there will be two lines of input. The first line has
N, the number of students in the class, followed by a space and then.
K the number of students needed to be present when class starts.
The second line of each case is
N space-separated integers, representing the arrival time of each student. Non-positive (
<= 0) arrival times denote that a particular student arrived early or on time; positive arrival times represent how many minutes late a student was to class. On time is not late.
YES for each case if the class is canceled; print
-1 -3 4 2
0 -1 2 1
For the first case,
K = 3 so three students must be present at the start of class for it to remain un-canceled. Only two show up, so the class is canceled.
For the second, Two students must be present at the start, and two are, so class continues.
I'll post a solution in one day.
problem source here