結果

問題 No.143 豆
ユーザー hippolover02
提出日時 2022-07-20 17:30:22
言語 Java
(openjdk 23)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 571 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 73,728 KB
実行使用メモリ 41,620 KB
最終ジャッジ日時 2024-07-02 13:51:30
合計ジャッジ時間 5,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ!!
        Scanner sc = new Scanner(System.in);
        int bean = sc.nextInt();
        int pack = sc.nextInt();
        int fam = sc.nextInt();
        int cnt = 0;
        
        for(int i=0;i<fam;i++){
            cnt += sc.nextInt();
        }
        if((bean * pack - cnt) >= 0){
            System.out.println(bean * pack - cnt);
        } else{
            System.out.println(-1);
        }
    }
}
0