Taps
InterviewTime limit1sMemory limit128 MB
Close the fewest flowing taps so the average temperature of the water still flowing reaches at least w.
Problem
An industrial plant has taps that water can flow from. Each tap has a gauge showing the temperature of the water for that tap. Water flows from a tap only if its set temperature is greater than . Every tap releases water at the same rate, and all of it collects in one shared reservoir.
Given the temperature of each tap, find the minimum number of taps you must close so that the water temperature in the reservoir is at least .
Assume the reservoir temperature equals the average temperature of all taps that water is flowing from. The temperature is not affected by the surrounding air.
Input
The first line contains two integers and , the number of taps and the target temperature (, ). The second line contains integers , where is the water temperature set for the -th tap ().
Output
Print a single integer: the minimum number of taps to close so that the reservoir temperature is at least degrees. If such a temperature cannot be reached, print the single word NIE instead.
Hint
To raise the average with as few closures as possible, close the flowing taps (those with a positive temperature) starting from the lowest temperature.