問題一覧 > 通常問題

No.2093 Shio Ramen

レベル : / AI推定難易度 : 500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 167
作問者 : tohohogisu / テスター : 👑 箱星
お気に入りにしたユーザー ProblemId : 8589 / 自分の提出
問題文最終更新日: 2023-07-13 13:18:42
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
yukicoder contest 363 (順位表) の他の問題:

Problem Statement

Taro is particular about his food, but Jiro is a big eater.
On Jiro's table there are \(N\) bowls of shio ramen. The shio ramen are numbered \(1,2, \cdots N\).
For each \(i\), shio ramen \(i\) has a saltiness of \(s_i\) and a flavor richness of \(a_i\). Like Taro, Jiro loves shio ramen, and Jiro wants to eat shio ramen with as rich a flavor as possible.
Jiro is bold, so he does not care how salty the shio ramen is.
However, if Jiro eats a combination of shio ramen whose total saltiness exceeds \(I\), he will get sick.
As Jiro's friend, among the combinations of the \(N\) bowls of shio ramen that will not make Jiro sick,
please tell Jiro the total flavor richness of the combination that maximizes the total flavor richness.

Input

\(N\) \(I\)
\(s_1\) \(a_1\)
\(s_2\) \(a_2\)
\(\vdots\)
\(s_N\) \(a_N\)

Constraints
\(1 \leq N,I \leq 1000\)
\(1 \leq s_i,a_i \leq 1000\) (\(1 \leq i \leq N\))
All inputs are integers

Sample

Sample 1
Input
3 3
2 3
3 4
1 2
Output
5

By choosing shio ramen \(1\) and shio ramen \(3\), the total saltiness is \(2+1\), which is \(3\), and the total flavor richness is \(3+2\), which is \(5\).
It is impossible for Jiro to make the total flavor richness greater than \(5\) without getting sick, so output \(5\).

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。