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

6205번 - The Fewest Coins 다국어

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

문제

Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coins he uses to pay plus the number of coins he receives in change is minimized. Help him to determine what this minimum number is.

FJ wants to buy T (1 <= T <= 10,000) cents of supplies. The currency system has N (1 <= N <= 100) different coins, with values V1, V2, ..., VN (1 <= Vi <= 120). Farmer John is carrying C1 coins of value V1, C2 coins of value V2, ...., and CN coins of value VN (0 <= Ci <= 10,000). The shopkeeper has an unlimited supply of all the coins, and always makes change in the most efficient manner (although Farmer John must be sure to pay in a way that makes it possible to make the correct change).

입력

  • Line 1: Two space-separated integers: N and T.
  • Line 2: N space-separated integers, respectively V1, V2, ..., VN coins (V1...VN).
  • Line 3: N space-separated integers, respectively C1, C2, ..., CN

출력

  • Line 1: A line containing a single integer, the minimum number of coins involved in a payment and change-making. If it is impossible for Farmer John to pay and receive exact change, output -1.

제한

예제 입력 1

3 70
5 25 50
5 2 1

예제 출력 1

3

힌트

Farmer John pays 75 cents using a 50 cents and a 25 cents coin, and receives a 5 cents coin in change, for a total of 3 coins used in the transaction.

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO December 2006 Contest > Gold 2번

  • 데이터를 추가한 사람: dotorya
(追記) (追記ここまで)

출처

대학교 대회

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

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