結果

問題 No.143 豆
ユーザー S1ho
提出日時 2017-02-19 15:18:50
言語 Java
(openjdk 23)
結果
AC  
実行時間 143 ms / 1,000 ms
コード長 547 bytes
コンパイル時間 3,324 ms
コンパイル使用メモリ 74,712 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-07-23 10:41:40
合計ジャッジ時間 6,418 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Beans {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        int k = scanner.nextInt();
        int n = scanner.nextInt();
        int f = scanner.nextInt();
        
        int allBeans = k * n;
        
        for(int i=0;i<f;i++){
            allBeans -= scanner.nextInt();
        }
        
        if(allBeans >= 0)
            System.out.println(allBeans);
        else{
            System.out.println(-1);
        }
    }
    
}
0