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

5994번 - Allowance 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB31222172.414%

문제

As a reward for record milk production, Farmer John has decided to start paying Bessie a small weekly allowance.

FJ has a set of coins in N (1 <= N <= 20) different denominations, where each denomination of coin evenly divides the next-larger denomination.

Using the given set of coins, he would like to pay Bessie at least some given amount of money C (1 <= C <= 100,000,000) every week. Please help him compute the maximum number of weeks he can pay Bessie.

입력

  • Line 1: Two space-separated integers: N and C
  • Lines 2..N+1: Each line corresponds to a denomination of coin and contains two integers: the value V (1 <= V <= 100,000,000) of the denomination, and the number of coins B (1 <= B <= 1,000,000) of this denomation in Farmer John's possession.

출력

  • Line 1: A single integer that is the number of weeks Farmer John can pay Bessie at least C allowance

제한

예제 입력 1

3 6
10 1
1 100
5 120

예제 출력 1

111

힌트

FJ can overpay Bessie with the one 10-cent coin for 1 week, then pay Bessie two 5-cent coins for 10 weeks and then pay Bessie one 1-cent coin and one 5-cent coin for 100 weeks.

출처

Olympiad > USA Computing Olympiad > 2009-2010 Season > USACO October 2009 Contest > Gold 7번

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO October 2005 Contest > Silver ?번

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

출처

대학교 대회

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

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