結果

問題 No.143 豆
ユーザー chiho_miyako
提出日時 2015-04-06 22:39:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 139 ms / 1,000 ms
コード長 548 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 54,332 KB
最終ジャッジ日時 2024-07-23 10:17:36
合計ジャッジ時間 5,341 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
       int k = koko.nextInt();
       int n = koko.nextInt();
       int f = koko.nextInt();
       int[] a = new int[f];
       int rest;
       int all = 0;
       for(int i = 0; i<f; i++){
           a[i] = koko.nextInt();
           all = all + a[i];
       }
       if(k*n>=all){
           rest = k*n-all;
       }else{
           rest = -1;
       }
       System.out.println(rest);
    }
}
0