結果

問題 No.143 豆
ユーザー mattyan0502mattyan0502
提出日時 2019-11-12 17:57:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 563 bytes
コンパイル時間 3,122 ms
コンパイル使用メモリ 72,744 KB
実行使用メモリ 56,216 KB
最終ジャッジ日時 2023-09-30 17:41:43
合計ジャッジ時間 5,056 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,728 KB
testcase_01 AC 131 ms
55,932 KB
testcase_02 AC 128 ms
55,728 KB
testcase_03 AC 132 ms
55,396 KB
testcase_04 AC 130 ms
53,912 KB
testcase_05 AC 132 ms
56,004 KB
testcase_06 AC 132 ms
55,788 KB
testcase_07 AC 133 ms
55,744 KB
testcase_08 AC 132 ms
55,404 KB
testcase_09 AC 130 ms
55,796 KB
testcase_10 AC 130 ms
55,740 KB
testcase_11 AC 128 ms
55,676 KB
testcase_12 AC 129 ms
56,216 KB
testcase_13 AC 131 ms
55,864 KB
testcase_14 AC 132 ms
55,852 KB
testcase_15 AC 132 ms
55,868 KB
testcase_16 AC 125 ms
56,048 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 sum = 0;
        int ans = 0;
        for(int i=0;i<F;i++)
        {
            int A = sc.nextInt();
            sum += A;
        }
        int all = K * N; 
        if(all<sum)
        {
            System.out.println(-1);
        }
        else
        {
            System.out.println(all-sum);
        }
        
    }
}
0