#K90497. Minimum Efficiency Sum
Minimum Efficiency Sum
Minimum Efficiency Sum
You are given T teams with M employees in each team. Each employee has an efficiency score. Your task is to select exactly one employee from each team so that the sum of the selected employees' efficiency scores is minimized, but the total must be at least a given threshold X. If it is not possible to achieve the threshold, output -1.
The problem can be formally described as follows. Given positive integers \(M\), \(T\), and \(X\), and a two-dimensional array \(efficiencies\) of size \(T \times M\) where each \(efficiencies[i][j]\) represents the efficiency of the \(j\)-th employee in the \(i\)-th team, find the minimum sum \(S\) such that:
[ S = \sum_{i=1}^{T} e_i \quad \text{with} \quad e_i \in efficiencies[i]\quad \text{and} \quad S \ge X ]
If no such combination exists then output -1.
Note: The input should be processed from standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The input is given in the following format from stdin:
- The first line contains three integers M, T, and X separated by spaces.
- The next T lines each contain M integers representing the efficiency scores of the employees in each team.
For example:
3 2 5 3 2 4 1 5 2
outputFormat
The output is a single integer printed to stdout, which is the minimum sum of efficiency scores that is not less than \(X\). If no valid combination exists, output -1.
## sample3 2 5
3 2 4
1 5 2
5