結果

問題 No.143 豆
ユーザー koukonkokoukonko
提出日時 2015-12-12 16:15:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 44 ms / 1,000 ms
コード長 669 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 72,128 KB
実行使用メモリ 49,900 KB
最終ジャッジ日時 2023-09-30 16:40:06
合計ジャッジ時間 3,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,220 KB
testcase_01 AC 42 ms
49,444 KB
testcase_02 AC 42 ms
49,212 KB
testcase_03 AC 44 ms
49,900 KB
testcase_04 AC 44 ms
47,824 KB
testcase_05 AC 43 ms
49,292 KB
testcase_06 AC 43 ms
47,420 KB
testcase_07 AC 43 ms
49,376 KB
testcase_08 AC 44 ms
49,164 KB
testcase_09 AC 43 ms
49,352 KB
testcase_10 AC 43 ms
49,220 KB
testcase_11 AC 43 ms
49,304 KB
testcase_12 AC 43 ms
49,376 KB
testcase_13 AC 43 ms
49,252 KB
testcase_14 AC 44 ms
49,824 KB
testcase_15 AC 44 ms
49,232 KB
testcase_16 AC 42 ms
49,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		try {

			String[] line = read.readLine().split(" ");
			int count = Integer.parseInt(line[0]) * Integer.parseInt(line[1]);
			int f = Integer.parseInt(line[2]);

			line = read.readLine().split(" ");
			int total = 0;
			for(int i = 0; i < f; ++i){
				total += Integer.parseInt(line[i]);
			}

			if(total > count){
				System.out.println(-1);
			}else{
				System.out.println(count - total);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
0