結果

問題 No.143 豆
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 21:45:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 3,301 ms
コンパイル使用メモリ 74,624 KB
実行使用メモリ 54,344 KB
最終ジャッジ日時 2024-05-01 15:18:08
合計ジャッジ時間 6,594 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
53,976 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 134 ms
54,220 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 140 ms
54,344 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
        }
        int opened = sum / beans;
        if (sum % beans != 0) {
            opened++;
        }
        System.out.println((packages - opened) * beans);
    }
}
0