結果

問題 No.143 豆
ユーザー NewbiekunNewbiekun
提出日時 2019-02-20 17:31:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 633 bytes
コンパイル時間 3,809 ms
コンパイル使用メモリ 71,860 KB
実行使用メモリ 56,076 KB
最終ジャッジ日時 2023-09-30 17:26:24
合計ジャッジ時間 6,624 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,712 KB
testcase_01 AC 139 ms
55,420 KB
testcase_02 AC 134 ms
55,872 KB
testcase_03 AC 135 ms
55,592 KB
testcase_04 AC 134 ms
55,824 KB
testcase_05 AC 133 ms
55,588 KB
testcase_06 AC 134 ms
55,576 KB
testcase_07 AC 135 ms
55,592 KB
testcase_08 AC 134 ms
55,880 KB
testcase_09 AC 137 ms
55,608 KB
testcase_10 AC 135 ms
56,076 KB
testcase_11 AC 131 ms
56,032 KB
testcase_12 AC 137 ms
55,940 KB
testcase_13 AC 140 ms
55,752 KB
testcase_14 AC 137 ms
55,972 KB
testcase_15 AC 136 ms
56,004 KB
testcase_16 AC 125 ms
55,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No143
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(); // 1袋に入っている数
		int n = sc.nextInt(); // 袋の数
		int f = sc.nextInt(); // 人数

		int[] age = new int[ f ];
		for( int i=0; i<f; i++ ){ age[ i ] = sc.nextInt(); }

// 総数(k*n)を求めて、配列から要素を1つずつ出して引いていく
		int total = k*n;
		for( int i = (age.length - 1); i >= 0; i-- )
		{ total -= age[ i ]; }

// 豆の合計が -1 以下になったら -1
		if( total <= -1 ){ total = -1; }
		System.out.println( total );
	}
}
0