No.2424 Josouzai
Problem Statement
Takahashi, who works at a certain company, wants to wither the vegetation on as many plots of land as possible.
There are plots of land numbered $1, 2, \dots, N$, and Takahashi initially has $K$ units of a chemical that withers vegetation.
For each plot $i$, $A_i$ units of the chemical are required to wither the vegetation on that plot.
Output the maximum number of plots on which the vegetation can be withered, and the maximum number of units of the chemical left over when the number of plots withered is at its maximum.
Input
$N\ K$ $A_1\ A_2\ ...\ A_N$
- $1 \leq N \leq 2 \times 10^5$
- $1 \leq K \leq 10^9$
- $1 \leq A_i \leq 10^9$
- All input values are integers.
Output
Output the maximum number of plots on which the vegetation can be withered and the maximum number of units of the chemical left over when the number of plots withered is at its maximum, separated by a space.
Sample
Sample 1
Input
5 11 4 1 2 6 3
Output
4 1
If the $1$st, $2$nd, $3$rd, and $5$th plots are chosen, the number of plots withered is $4$, which is the maximum.
Also, when the number of plots withered takes its maximum value of $4$, the maximum number of units left over is $11 - 10 = 1$.
Sample 2
Input
2 4 3 2
Output
1 2
The maximum number of plots on which the vegetation can be withered is $1$, but choosing the $2$nd plot maximizes the number of units of the chemical left over.
Sample 3
Input
10 158260522 77914575 2436426 24979445 61648772 23690081 33933447 76190629 62703497 11047202 71407775
Output
6 525149
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
chebrinko
0214sh7
tatyam
noya2