結果

問題 No.143 豆
ユーザー syusyu
提出日時 2020-08-25 20:09:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 494 bytes
コンパイル時間 3,638 ms
コンパイル使用メモリ 71,336 KB
実行使用メモリ 56,272 KB
最終ジャッジ日時 2023-09-30 17:55:39
合計ジャッジ時間 6,614 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,992 KB
testcase_01 AC 132 ms
55,364 KB
testcase_02 AC 129 ms
55,876 KB
testcase_03 AC 131 ms
55,744 KB
testcase_04 AC 131 ms
56,272 KB
testcase_05 AC 131 ms
55,372 KB
testcase_06 AC 131 ms
55,284 KB
testcase_07 AC 132 ms
55,796 KB
testcase_08 AC 132 ms
55,908 KB
testcase_09 AC 130 ms
55,996 KB
testcase_10 AC 129 ms
55,876 KB
testcase_11 AC 126 ms
55,644 KB
testcase_12 AC 129 ms
55,948 KB
testcase_13 AC 129 ms
55,368 KB
testcase_14 AC 131 ms
55,368 KB
testcase_15 AC 131 ms
55,592 KB
testcase_16 AC 122 ms
55,644 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 beansNumber=k*n;
        for(int i=0;i<f;i++){
            int age=sc.nextInt();
            beansNumber-=age;
        }
        if(beansNumber<0){
            System.out.println(-1);
        }else{
            System.out.println(beansNumber);
        }
    }
}
0