結果

問題 No.143 豆
ユーザー KatoooooKatooooo
提出日時 2017-09-14 14:35:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 712 bytes
コンパイル時間 2,977 ms
コンパイル使用メモリ 71,004 KB
実行使用メモリ 56,400 KB
最終ジャッジ日時 2023-09-30 17:07:39
合計ジャッジ時間 5,754 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,160 KB
testcase_01 AC 128 ms
55,552 KB
testcase_02 AC 127 ms
55,652 KB
testcase_03 AC 127 ms
55,744 KB
testcase_04 AC 128 ms
55,748 KB
testcase_05 AC 129 ms
55,860 KB
testcase_06 AC 128 ms
55,828 KB
testcase_07 AC 129 ms
55,772 KB
testcase_08 AC 129 ms
56,400 KB
testcase_09 AC 130 ms
55,848 KB
testcase_10 AC 128 ms
55,656 KB
testcase_11 AC 125 ms
55,424 KB
testcase_12 AC 126 ms
55,596 KB
testcase_13 AC 128 ms
56,000 KB
testcase_14 AC 129 ms
56,100 KB
testcase_15 AC 130 ms
53,696 KB
testcase_16 AC 120 ms
55,356 KB
権限があれば一括ダウンロードができます

ソースコード

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 all_beans = K*N;
        
        int all_old = 0;
        for(int i=0; i<F; i++){
            all_old += A[i];
        }
        
        if(all_beans - all_old>=0){
            System.out.println(all_beans - all_old);
        }else{
            System.out.println(-1);
        }
        
    }
}
0