Logo
(追記) (追記ここまで)

33535번 - Impressive Beers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 2048 MB36262470.588%

문제

You and your friends find yourselves in a bar after class. As you are a really big fan of specialty beers you want to drink as many different beers as possible. Only issue of course being that you are still a student, and therefore you do not have enough money to buy every beer in the pub.

But of course, all beers are not created equally! You know of every type of beer the price and how much happiness it will give you. As you want to be as happy as possible, and being a Delft student, you want to find out how much happiness you can buy using an optimal strategy. So you decide to write a program that tells you how much happiness you can buy with a given amount of money. But since you like to drink different beers, you will never order the same beer twice, your program should take this into account.

입력

One line with two integers: $N, 1 \le N \le 500$ the number of different beers the pub offers, and $M, 1 \le M \le 10000$ the amount of money that you have.

Followed by $N$ lines with on each line a type of beer which is indicated by two integers: $p, 1 \le p \le 1000,ドル the price of the beer and $h, 1 \le h \le 1000,ドル the happiness you will gain from this beer.

출력

A single line with a single integer $H,ドル the maximal happiness you can gain by buying different kinds of beers, within your budget.

제한

예제 입력 1

5 20
20 50
10 30
5 15
4 12
9 20

예제 출력 1

57

In the first sample your max happiness will be 57, as you can buy the beers priced 10, 5 and 4 to come to a hapiness of 57 (with a singe coin left to spend, buy there is no more beer you could buy for this price). Every other combination will give you less hapiness or will cost more than your budget. (for example, the beers of 10 + 9 will give you only 50 hapiness).

예제 입력 2

5 100
20 50
10 30
5 15
4 12
9 20

예제 출력 2

127

In the second sample you will buy each beer, giving you 127 hapiness, but it will not give you any more satisfaction to buy the same beer multiple times, so you are stuck at 127 and have some money left.

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2018 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /