結果

問題 No.143 豆
ユーザー bellbell
提出日時 2021-02-11 11:33:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 532 bytes
コンパイル時間 1,896 ms
コンパイル使用メモリ 71,484 KB
実行使用メモリ 56,272 KB
最終ジャッジ日時 2023-09-30 18:00:54
合計ジャッジ時間 4,985 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
54,108 KB
testcase_01 AC 132 ms
56,096 KB
testcase_02 AC 128 ms
55,956 KB
testcase_03 AC 129 ms
55,660 KB
testcase_04 AC 131 ms
55,948 KB
testcase_05 AC 131 ms
55,660 KB
testcase_06 AC 133 ms
55,860 KB
testcase_07 AC 133 ms
55,716 KB
testcase_08 AC 130 ms
56,128 KB
testcase_09 AC 129 ms
55,764 KB
testcase_10 AC 130 ms
56,272 KB
testcase_11 AC 126 ms
55,484 KB
testcase_12 AC 130 ms
55,848 KB
testcase_13 AC 131 ms
56,080 KB
testcase_14 AC 132 ms
55,756 KB
testcase_15 AC 133 ms
56,076 KB
testcase_16 AC 122 ms
56,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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=0;
        int min=0;

        for(int i=0; i<F; i++){
            A=sc.nextInt();
            if(min<=K*N){
                min+=A;
            }
        }

        if(min<=K*N){
        System.out.println(K*N-min);
        }else{
            System.out.println(-1);
        }
        sc.close();
    }
}
0