結果

問題 No.143 豆
ユーザー jonki324jonki324
提出日時 2018-06-04 10:40:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 591 bytes
コンパイル時間 3,068 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 56,004 KB
最終ジャッジ日時 2023-09-30 17:17:48
合計ジャッジ時間 5,213 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,884 KB
testcase_01 AC 135 ms
55,416 KB
testcase_02 AC 131 ms
55,964 KB
testcase_03 AC 132 ms
55,860 KB
testcase_04 AC 133 ms
55,984 KB
testcase_05 AC 134 ms
55,824 KB
testcase_06 AC 134 ms
55,668 KB
testcase_07 AC 134 ms
55,760 KB
testcase_08 AC 134 ms
55,796 KB
testcase_09 AC 136 ms
55,640 KB
testcase_10 AC 134 ms
55,932 KB
testcase_11 AC 130 ms
55,272 KB
testcase_12 AC 135 ms
55,772 KB
testcase_13 AC 133 ms
55,932 KB
testcase_14 AC 136 ms
56,004 KB
testcase_15 AC 137 ms
55,868 KB
testcase_16 AC 129 ms
55,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int n = scan.nextInt();
        int f = scan.nextInt();
        int[] a = new int[f];
        for (int i = 0; i < f; i++) {
            a[i] = scan.nextInt();
        }
        int ret = k * n;
        for (int i = 0; i < f; i++) {
            ret -= a[i];
            if (ret < 0) {
                ret = -1;
                break;
            }
        }
        System.out.println(ret);
        scan.close();
    }
}
0