結果

問題 No.143 豆
ユーザー Koketti1Koketti1
提出日時 2017-02-05 17:20:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 460 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 71,424 KB
実行使用メモリ 56,356 KB
最終ジャッジ日時 2023-09-30 16:56:17
合計ジャッジ時間 5,450 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,732 KB
testcase_01 AC 128 ms
55,568 KB
testcase_02 AC 125 ms
55,600 KB
testcase_03 AC 126 ms
55,748 KB
testcase_04 AC 128 ms
55,852 KB
testcase_05 AC 126 ms
56,356 KB
testcase_06 AC 128 ms
55,780 KB
testcase_07 AC 130 ms
56,140 KB
testcase_08 AC 129 ms
55,936 KB
testcase_09 AC 129 ms
55,724 KB
testcase_10 AC 128 ms
55,472 KB
testcase_11 AC 124 ms
55,884 KB
testcase_12 AC 127 ms
55,652 KB
testcase_13 AC 131 ms
55,756 KB
testcase_14 AC 131 ms
53,888 KB
testcase_15 AC 131 ms
54,344 KB
testcase_16 AC 121 ms
55,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();
		int N = scanner.nextInt();
		int F = scanner.nextInt();
		int beansSum = K * N;
		int ageSum = 0;
		
		for(int i = 0;i < F;i++){
			ageSum += scanner.nextInt();
		}
		if(beansSum < ageSum ){
			System.out.println(-1);
		}else{
			System.out.println(beansSum - ageSum);
		}
		scanner.close();
	}
}
0