結果

問題 No.143 豆
ユーザー howakuro
提出日時 2015-09-25 01:48:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 539 bytes
コンパイル時間 3,272 ms
コンパイル使用メモリ 74,988 KB
実行使用メモリ 54,484 KB
最終ジャッジ日時 2024-07-23 10:22:35
合計ジャッジ時間 6,291 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class Beanse {
	static Scanner scan= new Scanner(System.in);
	public static void main(String[] args) {
		int K = scan.nextInt();
		int N = scan.nextInt();
		int F = scan.nextInt()-1;
		ArrayList<Integer> A = new ArrayList<Integer>();
		for(int i=0;i<=F;i++){
			A.add(scan.nextInt());
		}
		
		int TotalBeans = K*N;
		for(int i=0;i<=F;i++){
			TotalBeans -= (int)A.get(i);
		}
		if(TotalBeans<0){
			System.out.println(-1);
		}else{
			System.out.println(TotalBeans);
		}
	}
}
0