結果

問題 No.143 豆
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-11 21:43:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 1,000 ms
コード長 595 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 71,988 KB
実行使用メモリ 57,796 KB
最終ジャッジ日時 2023-09-30 17:17:11
合計ジャッジ時間 6,428 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,620 KB
testcase_01 AC 133 ms
53,748 KB
testcase_02 AC 134 ms
55,408 KB
testcase_03 AC 134 ms
55,672 KB
testcase_04 AC 136 ms
55,660 KB
testcase_05 AC 133 ms
55,928 KB
testcase_06 AC 133 ms
55,724 KB
testcase_07 AC 133 ms
55,896 KB
testcase_08 AC 134 ms
57,796 KB
testcase_09 AC 135 ms
56,144 KB
testcase_10 AC 131 ms
55,808 KB
testcase_11 AC 128 ms
55,532 KB
testcase_12 AC 134 ms
55,812 KB
testcase_13 AC 133 ms
55,820 KB
testcase_14 AC 138 ms
55,660 KB
testcase_15 AC 138 ms
55,628 KB
testcase_16 AC 124 ms
55,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Setsubun{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int N = sc.nextInt();
        int num_beans = K*N;

        int F = sc.nextInt();
        int num_eats = 0;
        for(int i = 0; i < F; i++){
            num_eats += sc.nextInt();
        }

        if(num_beans >= num_eats){
            System.out.println(num_beans - num_eats);
        }else{
            System.out.println("-1");
        }
    }
}
0