結果

問題 No.143 豆
ユーザー dazydazy
提出日時 2016-09-03 15:21:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 651 bytes
コンパイル時間 3,403 ms
コンパイル使用メモリ 72,280 KB
実行使用メモリ 56,184 KB
最終ジャッジ日時 2023-09-30 16:49:55
合計ジャッジ時間 6,508 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,928 KB
testcase_01 AC 130 ms
55,988 KB
testcase_02 AC 129 ms
55,592 KB
testcase_03 AC 129 ms
55,760 KB
testcase_04 AC 130 ms
56,104 KB
testcase_05 AC 131 ms
56,184 KB
testcase_06 AC 131 ms
56,024 KB
testcase_07 AC 131 ms
55,360 KB
testcase_08 AC 130 ms
56,048 KB
testcase_09 AC 130 ms
55,952 KB
testcase_10 AC 130 ms
55,636 KB
testcase_11 AC 127 ms
55,892 KB
testcase_12 AC 128 ms
53,980 KB
testcase_13 AC 133 ms
55,944 KB
testcase_14 AC 130 ms
55,616 KB
testcase_15 AC 135 ms
55,468 KB
testcase_16 AC 122 ms
55,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Run {
    public static void main (String[] arg) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int N = scan.nextInt();
        int F = scan.nextInt();
        int[] A = new int[F];
        if (K < 1||K > 1000||N < 1||N > 1000||F < 1||F > 100) System.exit(1);
        int sum = 0;
        for (int i = 0; i < F; i++) {
            A[i] = scan.nextInt();
            if (A[i] < 1||A[i] > 100) System.exit(1);
            sum += A[i];
        }

        int left = K * N - sum;
        if (left < 0) System.out.println(-1);
        else System.out.println(left);
    }
}
0