Dodgeball
Output: Standard Output (stdout)
Memory limit: 256 megabytes
Time limit: 1.0 seconds
Your school is organising a dodgeball tournament! You have been tasked with creating a team, and want to create the largest team!
There are N people to choose from (1 \le N \le 100{,}000). Each person has specified skill level s_i (1 \le s_i \le 10{,}000). However, the organisers have imposed a limit on the total permissible skill level of a team. Specifically, you are given some integer K and the total skill level of your dodgeball team cannot exceed this value (1 \le K \le 1{,}000{,}000{,}000).
What is the size of the largest team you can form?
Input
- The first line of input will contain a single integer N — the amount of people you can choose from for your dodgeball team
- The second line of input will contain a single integer K — the limit on the total skill level of your team
- The next N lines will each contain a single integer s_i, representing the skill level of a player you can pick
Output
- Output a single integer — the size of the largest team you can form. Note that in some cases you may not be able to select anyone! In this case, simply output
0
Subtasks
- Subtask 1 (+11%): N=1 — That is, there is only one person to choose from
- Subtask 2 (+17%): s_i=1 for all i — That is, each player has a skill level of 1
- Subtask 3 (+23%): s_1=s_2=\cdots=s_{N-1}=s_N — That is, all players have the same skill level
- Subtask 4 (+27%): N \le 500
- Subtask 5 (+22%): No further constraints
Sample Explanations
Sample 1
In this case there are five players available to select for your team with skill levels 1, 3, 5, 7, 9. The total skill limit for your team is 10. You can take the players with skill levels 1, 3, and 5 for a total combined skill of 9. This gives you a team of size 3.
-
Sample Input 1
5 10 1 3 5 7 9
Sample Output 1
3 -
Sample Input 2
6 12 3 3 3 3 3 3
Sample Output 2
4