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

26995번 - Scales 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB68352251.163%

문제

Farmer John has a balance for weighing the cows. He also has a set of N (1 ≤ N ≤ 1000) weights with known masses (all of which fit in 31 bits) for use on one side of the balance. He places a cow on one side of the balance and then adds weights to the other side until they balance. (FJ cannot put weights on the same side of the balance as the cow, because cows tend to kick weights in his face whenever they can.) The balance has a maximum mass rating and will break if FJ uses more than a certain total mass C (1 ≤ C < 2^30) on one side.

The weights have the curious property that when lined up from smallest to biggest, each weight (from the third one on) has at least as much mass as the previous two combined.

FJ wants to determine the maximum mass that he can use his weights to measure exactly. Since the total mass must be no larger than C, he might not be able to put all the weights onto the scale.

Write a program that, given a list of weights and the maximum mass the balance can take, will determine the maximum legal mass that he can weigh exactly.

입력

  • Line 1: Two space-separated positive integers, N and C.
  • Lines 2..N+1: Each line contains a single positive integer that is the mass of one weight. The masses are guaranteed to be in non-decreasing order.

출력

  • Line 1: A single integer that is the largest mass that can be accurately and safely measured.

제한

예제 입력 1

3 15
1
10
20

예제 출력 1

11

힌트

출처

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

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

출처

대학교 대회

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

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