結果

問題 No.143 豆
ユーザー YamaKasaYamaKasa
提出日時 2018-04-19 15:46:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 649 bytes
コンパイル時間 2,444 ms
コンパイル使用メモリ 71,956 KB
実行使用メモリ 56,316 KB
最終ジャッジ日時 2023-09-30 17:16:24
合計ジャッジ時間 5,262 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,824 KB
testcase_01 AC 134 ms
55,624 KB
testcase_02 AC 131 ms
55,300 KB
testcase_03 AC 134 ms
55,624 KB
testcase_04 AC 133 ms
55,668 KB
testcase_05 AC 133 ms
55,620 KB
testcase_06 AC 133 ms
55,984 KB
testcase_07 AC 132 ms
55,704 KB
testcase_08 AC 132 ms
56,316 KB
testcase_09 AC 133 ms
55,948 KB
testcase_10 AC 134 ms
55,872 KB
testcase_11 AC 133 ms
55,824 KB
testcase_12 AC 135 ms
55,628 KB
testcase_13 AC 135 ms
55,360 KB
testcase_14 AC 133 ms
55,720 KB
testcase_15 AC 137 ms
55,516 KB
testcase_16 AC 127 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		//System.out.println("袋に入っている豆の数");
		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();
		//System.out.println("袋の数");
		int N = scanner.nextInt();

		//System.out.println("家族の人数");
		int F = scanner.nextInt();
		long b = K*N;	//豆の数
		int []A = new int[F];	//家族の年齢
		long e = 0;	//必要な豆の数
		for(int i = 0; i < F; i++) {
			A[i] = scanner.nextInt();
			e += A[i];
		}
		scanner.close();
		if(e <= b) {
			System.out.println(b - e);
		}else {
			System.out.println(-1);
		}
	}
}
0