結果

問題 No.143 豆
ユーザー N_Gakuto7N_Gakuto7
提出日時 2020-04-02 22:46:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 677 bytes
コンパイル時間 3,428 ms
コンパイル使用メモリ 71,812 KB
実行使用メモリ 56,008 KB
最終ジャッジ日時 2023-09-30 17:48:52
合計ジャッジ時間 6,638 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,812 KB
testcase_01 AC 126 ms
55,668 KB
testcase_02 AC 126 ms
55,368 KB
testcase_03 AC 128 ms
55,864 KB
testcase_04 AC 128 ms
55,628 KB
testcase_05 AC 128 ms
55,628 KB
testcase_06 AC 128 ms
55,668 KB
testcase_07 AC 130 ms
55,884 KB
testcase_08 AC 129 ms
56,008 KB
testcase_09 AC 131 ms
55,868 KB
testcase_10 AC 128 ms
55,600 KB
testcase_11 AC 127 ms
55,608 KB
testcase_12 AC 130 ms
55,900 KB
testcase_13 AC 130 ms
55,596 KB
testcase_14 AC 128 ms
55,604 KB
testcase_15 AC 130 ms
55,600 KB
testcase_16 AC 122 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
         
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){

            int perBz = Integer.parseInt(sc.next());
            int bz = Integer.parseInt(sc.next());
            int fam = Integer.parseInt(sc.next());
            
            int ageSum = 0;
            for(int i = 0; i < fam; i++){
                ageSum += Integer.parseInt(sc.next());
            }

            int ans = perBz * bz - ageSum; 
            if(ans >= 0) System.out.println(ans);
            else System.out.println(-1);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}
0