結果

問題 No.143 豆
ユーザー oyafusooyafuso
提出日時 2019-03-11 17:08:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 919 bytes
コンパイル時間 4,025 ms
コンパイル使用メモリ 83,328 KB
実行使用メモリ 56,360 KB
最終ジャッジ日時 2023-09-30 17:28:45
合計ジャッジ時間 6,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,332 KB
testcase_01 AC 118 ms
55,580 KB
testcase_02 AC 119 ms
55,836 KB
testcase_03 AC 120 ms
55,760 KB
testcase_04 AC 119 ms
55,708 KB
testcase_05 AC 121 ms
55,772 KB
testcase_06 AC 124 ms
55,968 KB
testcase_07 AC 123 ms
56,024 KB
testcase_08 AC 124 ms
55,956 KB
testcase_09 AC 122 ms
55,772 KB
testcase_10 AC 123 ms
55,616 KB
testcase_11 AC 120 ms
55,764 KB
testcase_12 AC 119 ms
55,756 KB
testcase_13 AC 122 ms
55,612 KB
testcase_14 AC 122 ms
54,416 KB
testcase_15 AC 123 ms
56,360 KB
testcase_16 AC 120 ms
55,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {

	private static final String SPLIT_STR = " ";

	public static void main(String[] args) {
		// Scanner生成
		Scanner sc = new Scanner(System.in);
		// 入力設定
		String input = sc.nextLine();
		String[] split = input.split(SPLIT_STR);
		int K = Integer.parseInt(split[0]);
		int N = Integer.parseInt(split[1]);
		int F = Integer.parseInt(split[2]);
		input = sc.nextLine();
		split = input.split(SPLIT_STR);
		List<Integer> numList = new ArrayList<>(split.length);
		for (int i = 0; i < split.length; i++) {
			numList.add(Integer.parseInt(split[i]));
		}
		// Scannerクローズ
		sc.close();

		/* メイン処理開始 */
		// 変数初期化
		int result = K * N;
		// 結果設定
		for (Integer num : numList) {
			result -= num;
			if (result < 0) {
				result = -1;
				break;
			}
		}
		/* メイン処理終了 */

		// 結果出力
		System.out.println(result);
	}
}
0