結果

問題 No.143 豆
ユーザー yonaka_gggyonaka_ggg
提出日時 2020-09-06 16:03:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 611 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 71,552 KB
実行使用メモリ 56,032 KB
最終ジャッジ日時 2023-09-30 17:56:10
合計ジャッジ時間 4,980 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,020 KB
testcase_01 AC 130 ms
55,996 KB
testcase_02 AC 132 ms
55,604 KB
testcase_03 AC 132 ms
53,348 KB
testcase_04 AC 130 ms
55,724 KB
testcase_05 AC 130 ms
55,552 KB
testcase_06 AC 133 ms
55,400 KB
testcase_07 AC 131 ms
55,984 KB
testcase_08 AC 129 ms
56,032 KB
testcase_09 AC 135 ms
55,576 KB
testcase_10 AC 133 ms
55,748 KB
testcase_11 AC 125 ms
55,684 KB
testcase_12 AC 129 ms
55,796 KB
testcase_13 AC 130 ms
55,688 KB
testcase_14 AC 132 ms
56,000 KB
testcase_15 AC 131 ms
55,356 KB
testcase_16 AC 121 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int f = sc.nextInt();
        int[] a = new int[f];
        for(int i = 0; i < f; i++)
            a[i] = sc.nextInt();

        int ans = Integer.MAX_VALUE;
        int beans = k * n;
        for(int ai : a) {
            beans -= ai;
            ans = beans;
            if(beans < 0) {
                ans = -1;
                break;
            }
        }

        System.out.println(ans);
    }

}
0