수용 인원이 k인 홀과 한 명만 작업하는 방에서 이루어지는 과정을 두 가지 방식으로 평가한 점수를 모든 순열에 대해 합산하고, 직원별로 두 점수를 곱해 10^9+7로 나눈 값을 구한다.
어려움9조합론수학동적 계획법정렬아직 제출이 없습니다시간 제한2초메모리 제한512 MBThere are n employees in the company Yooglex. The i-th employee has to work ti time units per day. These values are different for all employees. Yooglex work process is weird in such a way that at every moment in time only one employee can work, and the rest of them have to wait until he’s done.
Yooglex office consists of a hall and a room. No more than k employees can be in the hall at the same time. Employees form a queue outside the office to enter the hall. Then the next algorithm applies:
The board of Yooglex finally tasked themselves with evaluating their employees to assign sensible salaries. Two methods of evaluation have been coined.
The first one is quite simple. For each of n! possible permutations of employee queues and each employee i, the time between the first employee in the queue entering the room and employee i exiting the room is calculated. For each employee, these times are summed over all the n! queue permutations. The resulting sums are the final evaluation scores.
The second method is even simpler. For i-th employee and each queue permutation, consider all such employees j that tj > ti, but employee j is going to finish his job before employee i. The number of such employees j will be the score for employee i.
It has been decided that attempting to choose one of two methods is a fruitless task, and instead the third method has been suggested, which is simply a product of respective scores from the first two methods.
Can you calculate the third evaluation method scores quick enough?
The first line of input consists of two integers n and k: the number of employees and the hall capacity, respectively (1 ≤ n ≤ 300, 1 ≤ k ≤ n).
The second line consists of n integers t1, . . . , tn: the workloads of each employee (1 ≤ ti ≤ 109). All ti are different.
Output n integers: the evaluation scores for employees, listed in the same order as their workloads in the input. Since the scores can be very large, output them modulo 109 + 7.