結果

問題 No.143 豆
ユーザー yonaka_ggg
提出日時 2020-09-06 16:01:40
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 50,044 KB
最終ジャッジ日時 2024-11-29 07:14:14
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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[] a = new int[f];
        for(int i = 0; i < f; i++)
        	a[i] = sc.nextInt();
        
        int ans = Integer.MAX_VALUE;
        int beans = k * n;
        for(int ai : a) {
        	beans -= ai;
        	if(beans < 0) ans = -1;
        }
        
        System.out.println(Math.min(ans, beans));
    }

}
0