QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22734. 天秤

Statistics

Farmer John は牛用天秤と既知質量の $N$ ($1 \le N \le 1000$) 分銅(全 31 ビット以内)を片側に使います。牛を片側、分銅を他側へ平衡まで足します。同じ側では牛が機会ごとに顔に蹴り飛ばすので不可です。片側総質量が $C$ ($1 \le C < 2^{30}$) を超えると壊れます。

小さい順に並べると、第三以降は各分銅が直前二つの和以上という性質です。

正確に量れる最大質量を求めます。総量 $C$ 以下なので全分銅を載せられないかもしれません。

分銅リストと天秤上限から合法で正確に量れる最大を求めるプログラムを書いてください。

入力

1 行目:空白区切り正整数 $N$、$C$。

$2..N+1$ 行目:各一正整数の分銅質量、非減少順。

出力

1 行目:正確かつ安全な最大質量の整数。

入出力例

入力 1

3 15
1
10
20

出力 1

11

注記

分銅三つは 1、10、20、片側最大 15。

1 と 10 で 11 を量ります。それより大きく組める値は全て天秤を壊します。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.