| UTPC Spring 2026 Open Contest |
|---|
| Finished |
The UTPC officers have just arrived on planet Aerth (completely different from planet Earth), and are preparing to embark on an expedition across the solar system aboard their spaceship. Unfortunately, the ship operates on a strict launch schedule — it departs at exactly time $$$T$$$, with or without everyone on board.
The boarding ramp fits exactly one officer at a time. Each officer $$$i$$$ requires $$$b_i$$$ seconds to board. You may choose the order in which officers board. An officer successfully boards if they finish boarding by time $$$T$$$. The first officer begins boarding at time $$$0$$$.
The expedition cannot begin without as many officers as possible. Determine the maximum number of officers that can board the spaceship before it departs.
The first line contains two integers $$$n$$$ and $$$T$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$1 \leq T \leq 10^9$$$) — the number of officers and the departure time in seconds.
The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \leq b_i \leq 10^9$$$) — the time in seconds it takes each officer to board.
Print a single integer — the maximum number of officers that can board the spaceship before departure.
5 103 1 4 1 5
4
| Name |
|---|


