Cut the strips
You have N strips with the given lengths. You may make at most K cuts in total, each cut splitting one strip into two. Find the largest number of pieces of length exactly L you can end up with.
Reported in: Infosys (SP / DSE · 22 Nov 2026) (memory-based)
Input
First line: N K L. Second line: N strip lengths.
Output
The largest number of pieces of length L.
Constraints
1 ≤ N ≤ 10^5; 0 ≤ K ≤ 10^9; 1 ≤ L, lengths ≤ 10^9.
Example 1
Input:
3 3 4
8 4 6
Output:
4Example 2
Input:
2 1 3
9 7
Output:
1Example 3
Input:
4 0 5
5 10 3 5
Output:
2Hint: Each cut gives one piece of length L, except that a strip whose length is an exact multiple of L gives its last piece free (a strip of exactly L needs no cut at all). Finish those strips first, shortest first, then spend the cuts that are left anywhere.