No.2093 Shio Ramen
タグ : / 解いたユーザー数 167
作問者 :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。