結果

問題 No.143 豆
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 21:48:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 512 bytes
コンパイル時間 3,110 ms
コンパイル使用メモリ 72,188 KB
実行使用メモリ 57,700 KB
最終ジャッジ日時 2023-09-30 17:09:15
合計ジャッジ時間 6,211 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,748 KB
testcase_01 AC 129 ms
55,540 KB
testcase_02 AC 127 ms
55,720 KB
testcase_03 AC 131 ms
55,980 KB
testcase_04 AC 131 ms
55,556 KB
testcase_05 AC 128 ms
56,000 KB
testcase_06 AC 136 ms
56,276 KB
testcase_07 AC 132 ms
55,888 KB
testcase_08 AC 131 ms
56,220 KB
testcase_09 AC 132 ms
55,676 KB
testcase_10 AC 129 ms
55,584 KB
testcase_11 AC 127 ms
56,020 KB
testcase_12 AC 129 ms
55,584 KB
testcase_13 AC 131 ms
55,888 KB
testcase_14 AC 135 ms
57,700 KB
testcase_15 AC 133 ms
55,792 KB
testcase_16 AC 121 ms
55,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No143 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int beans = s.nextInt();
        int packages = s.nextInt();
        int people = s.nextInt();
        int sum = 0;
        for (int i = 0; i < people; i++) {
            sum += s.nextInt();
        }
        if (sum > beans * packages) {
            System.out.println(-1);
        } else {
            System.out.println(beans * packages - sum);
        }
    }
}
0