#C496. Minimum Total Cost Selection
Minimum Total Cost Selection
Minimum Total Cost Selection
You are given a list of n colors, each with a cost c_i and two binary flags a_i and b_i indicating whether Alice and Bob like the color, respectively.
Your task is to choose exactly k colors such that both Alice and Bob like them, and the total cost of the selected colors is minimized. If it is not possible to choose k colors liked by both of them, output -1.
The cost minimization is defined by the sum of the costs of the chosen colors.
Note: The input format requires reading from stdin and output should be printed to stdout.
inputFormat
The first line contains two integers n and k where n is the total number of colors and k is the required number of colors to select.
Each of the next n lines contains three integers c_i, a_i, and b_i representing the cost of the i-th color and whether Alice and Bob like it, respectively (1 for yes, 0 for no).
outputFormat
Print a single integer representing the minimum total cost required to select k colors that are liked by both Alice and Bob. If it is not possible, print -1.
## sample7 3
5 1 1
7 1 1
3 1 0
6 1 1
8 0 1
4 1 1
9 1 0
15