問題一覧 > 通常問題

No.2424 Josouzai

レベル : / AI推定難易度 : 194 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 213
作問者 : chebrinko / テスター : 0214sh7 tatyam ebi_fly noya2 👑 potato167 tassei903 ramdos ponjuice
お気に入りにしたユーザー ProblemId : 10008 / 自分の提出
問題文最終更新日: 2023-08-15 21:17:24
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
traP 作問ハッカソンコンテスト 001 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。