QOJ.ac

QOJ

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

#22773. 牛肉 McNuggets

Statistics

Farmer Brown の牛たちは、McDonalds が新商品「牛肉 McNuggets」の導入を検討していると聞いて激怒しています。牛たちはこの商品に悪い印象を与えるあらゆる方法を探しています。

牛たちの戦略の 1 つは「劣った包装」です。「見て」と牛たちは言います。「牛肉 McNuggets を $3$、$6$、$10$ 個入りの箱で売ると、$1,2,4,5,7,8,11,14,17$ 個欲しいお客さんには対応できない。悪い包装は悪い商品だ。」

牛たちを手伝ってください。$N$(包装の種類数、$1 \le N \le 10$)と、各包装の個数を表す $N$ 個の正整数($1 \le i \le 256$)が与えられます。指定された個数の包装を買うことで購入できない最大の個数を出力してください。すべての個数を購入できる場合、またはその最大個数に上限がない場合は $0$ を出力してください。

購入できない最大の個数が存在する場合、それは $2,000,000,000$ 以下です。

入力

  • 1 行目:包装の種類数 $N$。

  • $2..N+1$ 行目:1 種類の箱に入っている個数。

出力

出力ファイルの 1 行に、表現できない最大の個数を表す整数を出力してください。すべての個数を購入できる場合、または最大個数に上限がない場合は $0$ を出力してください。

入出力例

入力 1

3
3
6
10

出力 1

17

問題作成:Hubert Chen, 1998

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.