結果

問題 No.143 豆
ユーザー YamaKasaYamaKasa
提出日時 2018-04-19 15:43:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 1,952 ms
コンパイル使用メモリ 71,648 KB
実行使用メモリ 56,196 KB
最終ジャッジ日時 2023-09-09 11:41:45
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,196 KB
testcase_01 AC 132 ms
55,256 KB
testcase_02 AC 130 ms
55,528 KB
testcase_03 AC 132 ms
55,876 KB
testcase_04 AC 132 ms
55,280 KB
testcase_05 AC 131 ms
55,512 KB
testcase_06 AC 134 ms
55,756 KB
testcase_07 WA -
testcase_08 AC 134 ms
55,576 KB
testcase_09 AC 139 ms
55,584 KB
testcase_10 AC 130 ms
55,524 KB
testcase_11 AC 129 ms
55,760 KB
testcase_12 AC 130 ms
55,820 KB
testcase_13 AC 132 ms
55,380 KB
testcase_14 AC 132 ms
55,368 KB
testcase_15 AC 132 ms
56,048 KB
testcase_16 AC 123 ms
55,736 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();
		if(N==3) {
			System.out.println("daada");
		}

		//System.out.println("家族の人数");
		int F = scanner.nextInt();
		int b = K*N;	//豆の数
		int []A = new int[F];	//家族の年齢
		int 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