結果

問題 No.143 豆
ユーザー takutaku
提出日時 2020-09-16 16:50:08
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 2,433 ms
コンパイル使用メモリ 75,368 KB
実行使用メモリ 54,568 KB
最終ジャッジ日時 2024-06-22 03:22:16
合計ジャッジ時間 4,540 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main(String[] args) {
	    
	    // 入力情報を受け取る
	    Scanner sc = new Scanner(System.in);
	    int k = sc.nextInt();
	    int n = sc.nextInt();
	    int f = sc.nextInt();
	    
	    int sum = 0;
	    
	    // 必要な豆の総数
	    for(int i = 0; i < f; i++) {
	        sum += sc.nextInt();
	    }
	    
	    // 準備した豆の合計数
	    int num = k * n;
	    
	    if(num > sum) {
	        System.out.println(num - sum);
	    }else{
	        System.out.println("-1");
	    }
	    
	}
}

0