問題一覧 > 通常問題

No.143 Beans

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 64 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 1470
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 361 / 自分の提出
問題文最終更新日: 2024-05-04 03:14:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 83 (順位表) の他の問題:

Problem Statement

Yuki picked up $N$ bags, each containing exactly $K$ beans.
By the way, on Setsubun there is a custom of eating as many beans as one's age.
Yuki's family has $F$ members, whose ages are $A_1,A_2,\ldots,A_F$ years.
Find how many beans will finally remain after each of them eats as many beans as their age.
However, if not everyone can eat as many beans as their age, output $\verb|-1|$.


Figure 1. Today's haul (February 3, 2015, Seigan-ji Temple)

Input

$K$ $N$ $F$
$A_1$ $A_2$ $\cdots$ $A_F$

$1 \leq K \leq 1000$
$1 \leq N \leq 1000$
$1 \leq F \leq 100$
$1 \leq A_i \leq 100$

Output

Output the number of remaining beans, or output $\verb|-1|$.

Sample

Sample 1
Input
10 10 3
10 20 40
Output
30

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。