結果

問題 No.143 豆
ユーザー lotokalotoka
提出日時 2021-06-04 22:10:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 631 bytes
コンパイル時間 4,136 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 56,124 KB
最終ジャッジ日時 2023-08-12 13:16:58
合計ジャッジ時間 7,003 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,476 KB
testcase_01 AC 134 ms
55,688 KB
testcase_02 AC 131 ms
56,124 KB
testcase_03 AC 132 ms
54,132 KB
testcase_04 AC 135 ms
55,860 KB
testcase_05 AC 137 ms
55,856 KB
testcase_06 AC 136 ms
55,744 KB
testcase_07 AC 136 ms
55,512 KB
testcase_08 AC 135 ms
55,708 KB
testcase_09 AC 137 ms
55,936 KB
testcase_10 AC 133 ms
56,016 KB
testcase_11 AC 131 ms
55,896 KB
testcase_12 AC 133 ms
55,924 KB
testcase_13 AC 137 ms
55,556 KB
testcase_14 AC 136 ms
55,772 KB
testcase_15 AC 140 ms
55,784 KB
testcase_16 AC 127 ms
55,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int N = scanner.nextInt();
        int F = scanner.nextInt();
        int sig = K * N;
        
        int[] A = new int[F];
        
        for (int i = 0; i < F; i++){
            A[i] = scanner.nextInt();
        }
        
        for (int i = 0; i < F; i++){
            sig -= A[i];
        }
        
        if (sig < 0){
            System.out.println(-1);
        }
        
        else{
            System.out.println(sig);
        }
    }
}
0