結果

問題 No.143 豆
ユーザー samplelpmas
提出日時 2016-11-09 11:51:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 570 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 54,280 KB
最終ジャッジ日時 2024-07-23 10:38:34
合計ジャッジ時間 4,917 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numBeansPerPack = sc.nextInt();
        int numPacks = sc.nextInt();
        int numPeople = sc.nextInt();

        int numLeftovers = numBeansPerPack * numPacks;

        for (int i = 0; i < numPeople; i++) {

            int age = sc.nextInt();
            numLeftovers -= age;

        }

        if (numLeftovers < 0) {
            numLeftovers = -1;
        }

        System.out.println(numLeftovers);

    }

}
0