#C11583. Even Distribution of Vaccines

    ID: 40915 Type: Default 1000ms 256MiB

Even Distribution of Vaccines

Even Distribution of Vaccines

You are given one or more datasets representing a vaccine distribution scenario. In each dataset, there are N hospitals with specified maximum capacities and a total of M vaccines available. The vaccines must be distributed as evenly as possible among the hospitals while ensuring that no hospital receives more than its capacity. The distribution is performed sequentially on the hospitals in ascending order of their capacities.

For each hospital, the number of vaccines allocated is determined by taking the integer division of the remaining vaccines by the number of hospitals yet to be allocated, i.e., \( \text{allocation} = \min\Big(\left\lfloor \frac{\text{vaccines_left}}{(N-i)} \right\rfloor, \text{capacity}[i] \Big) \). After allocation for all hospitals, output the total vaccines distributed and the remaining vaccines (i.e. \(M - \text{distributed}\)).

It is guaranteed that the process terminates properly and the sum of distributions never exceeds the available vaccines.

inputFormat

The first line of the input contains an integer \(T\) representing the number of test cases.
For each test case, the first line contains two integers \(N\) and \(M\) separated by a space, where \(N\) is the number of hospitals and \(M\) is the total number of vaccines available.
The second line contains \(N\) space-separated integers, where each integer represents the maximum capacity of a hospital.

outputFormat

For each test case, output a single line containing two space-separated integers: the total number of vaccines distributed and the number of vaccines that remain undistributed.

## sample
1
4 1000
300 500 200 100
1000 0