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

6187번 - Going to the Movies 다국어

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

문제

Farmer John is taking some of his cows to the movies! While his truck has a limited capacity of C (100 <= C <= 5000) kilograms, he wants to take the cows that, in aggregate, weigh as much as possible without exceeding the limit C.

Given N (1 <= N <= 16) cows and their respective weights W_i, determine the weight of the heaviest group of cows that FJ can take to the movies.

입력

  • Line 1: Two space-separated integers: C and N
  • Lines 2..N+1: Line i+1 contains a single integer: W_i

출력

  • Line 1: A single integer that is the weight of the heaviest group of cows that can go to the movies

제한

예제 입력 1

259 5
81
58
42
33
61

예제 출력 1

242

힌트

81+たす58+たす42+たす61 = 242; this is the best possible sum

출처

Olympiad > USA Computing Olympiad > 2007-2008 Season > USACO US Open 2008 Contest > Bronze 2번

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

출처

대학교 대회

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

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