#P17379. [PacNW 2025] Bouquet of Balloons

[PacNW 2025] Bouquet of Balloons

Problem Description

On their journey to the World Finals, Team Shuchiin Academy must first conquer the North America Championship. The problem set contains nn problems, and problem ii takes sis_i minutes to solve. The team may solve the problems in any order, but it cannot work on multiple problems in parallel. It must finish its current problem before starting another one. Whenever the team solves a problem, the judges immediately bring it a fully inflated balloon.

Chika Fujiwara, the team's resident troll, decides to tie all the balloons to the team's lucky die so that it floats. When the team receives a balloon, it contains 11 liter of helium and can lift 11 gram. Every balloon has a lifetime of dd minutes. It deflates at a constant rate of 1/d1/d liters per minute, and its lifting capacity decreases at the same rate. For example, after d/3d/3 minutes, a balloon can lift 2/32/3 grams. After dd minutes, its lifting capacity is 00.

The die floats if, at any moment, the total lifting capacity of all the team's balloons is at least the die's mass mm. The mass of the balloons themselves is negligible.

Given the problem-solving times, the balloon lifetime dd, and the die mass mm, find the minimum number of problems Team Shuchiin Academy must solve to make the die float. If it is impossible, output 1-1.

Input Format

The first line contains three integers nn, dd, and mm (1n,d,m1051\le n,d,m\le10^5): the number of problems, the lifetime of each balloon, and the mass of the die.

The second line contains nn integers s1,s2,,sns_1,s_2,\ldots,s_n (1si1051\le s_i\le10^5), the times needed to solve the problems.

Output Format

Output the minimum number of problems the team must solve to make the die float, or 1-1 if this is impossible.

3 4 2
1 5 2
3
4 5 2
1 2 4 6
3
5 14 3
1 2 4 6 8
4
5 12 3
2 2 3 3 4
5
5 10 3
2 2 3 3 4
-1