結果

問題 No.143 豆
ユーザー hikari2004hikari2004
提出日時 2016-04-20 14:53:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 600 bytes
コンパイル時間 3,326 ms
コンパイル使用メモリ 72,644 KB
実行使用メモリ 56,076 KB
最終ジャッジ日時 2023-09-30 16:44:58
合計ジャッジ時間 6,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,324 KB
testcase_01 AC 125 ms
55,624 KB
testcase_02 AC 125 ms
55,768 KB
testcase_03 AC 127 ms
55,600 KB
testcase_04 AC 125 ms
55,852 KB
testcase_05 AC 126 ms
55,660 KB
testcase_06 AC 127 ms
55,628 KB
testcase_07 AC 128 ms
55,744 KB
testcase_08 AC 126 ms
55,484 KB
testcase_09 AC 127 ms
55,520 KB
testcase_10 AC 126 ms
55,492 KB
testcase_11 AC 126 ms
55,428 KB
testcase_12 AC 128 ms
55,884 KB
testcase_13 AC 124 ms
55,464 KB
testcase_14 AC 127 ms
56,076 KB
testcase_15 AC 129 ms
55,788 KB
testcase_16 AC 127 ms
55,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No143 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineSplit = line.split(" ");
		int k = Integer.parseInt(lineSplit[0]);
		int n = Integer.parseInt(lineSplit[1]);
		int f = Integer.parseInt(lineSplit[2]);

		String line2 = sc.nextLine();
		String[] family = line2.split(" ");
		int beans = k * n;

		for(int i = 0; i < family.length; i++){
			int age = Integer.parseInt(family[i]);
			beans -= age;
			if(beans < 0){
				beans = -1;
			}
		}
		System.out.println(beans);
	}

}
0