結果

問題 No.143 豆
ユーザー hikari2004
提出日時 2016-04-20 14:53:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 600 bytes
コンパイル時間 3,505 ms
コンパイル使用メモリ 74,624 KB
実行使用メモリ 54,356 KB
最終ジャッジ日時 2024-07-23 10:29:37
合計ジャッジ時間 6,242 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No143 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineSplit = line.split(" ");
		int k = Integer.parseInt(lineSplit[0]);
		int n = Integer.parseInt(lineSplit[1]);
		int f = Integer.parseInt(lineSplit[2]);

		String line2 = sc.nextLine();
		String[] family = line2.split(" ");
		int beans = k * n;

		for(int i = 0; i < family.length; i++){
			int age = Integer.parseInt(family[i]);
			beans -= age;
			if(beans < 0){
				beans = -1;
			}
		}
		System.out.println(beans);
	}

}
0