結果

問題 No.143 豆
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-29 17:49:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 68 ms / 1,000 ms
コード長 907 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 76,772 KB
実行使用メモリ 50,872 KB
最終ジャッジ日時 2023-09-30 17:01:47
合計ジャッジ時間 4,330 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
50,412 KB
testcase_01 AC 59 ms
50,512 KB
testcase_02 AC 59 ms
50,512 KB
testcase_03 AC 59 ms
50,840 KB
testcase_04 AC 60 ms
50,584 KB
testcase_05 AC 59 ms
50,416 KB
testcase_06 AC 59 ms
50,644 KB
testcase_07 AC 59 ms
50,548 KB
testcase_08 AC 59 ms
50,340 KB
testcase_09 AC 59 ms
48,500 KB
testcase_10 AC 68 ms
50,432 KB
testcase_11 AC 59 ms
50,488 KB
testcase_12 AC 60 ms
50,556 KB
testcase_13 AC 60 ms
50,516 KB
testcase_14 AC 59 ms
50,524 KB
testcase_15 AC 59 ms
50,872 KB
testcase_16 AC 58 ms
50,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int K = Integer.parseInt(inputs[0]);
        int N = Integer.parseInt(inputs[1]);
        int F = Integer.parseInt(inputs[2]);

        int sum = K * N;
        inputs =  reader.readLine().split(" ");
        int[] eatBeans = Stream.of(inputs).mapToInt(Integer::parseInt).toArray();
        for (int i = 0; i < F; i++) {
            sum -= eatBeans[i];
        }
        if(sum <0) {
            System.out.println(-1);
        } else {
            System.out.println(sum);
        }

    }
}
0