結果

問題 No.143 豆
ユーザー takutakutakutaku
提出日時 2020-09-16 16:50:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 2,762 ms
コンパイル使用メモリ 71,584 KB
実行使用メモリ 56,396 KB
最終ジャッジ日時 2023-09-04 03:40:48
合計ジャッジ時間 6,107 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,768 KB
testcase_01 AC 128 ms
55,864 KB
testcase_02 AC 126 ms
55,868 KB
testcase_03 AC 128 ms
56,012 KB
testcase_04 AC 128 ms
55,804 KB
testcase_05 AC 130 ms
55,936 KB
testcase_06 AC 129 ms
55,472 KB
testcase_07 AC 129 ms
55,768 KB
testcase_08 AC 130 ms
55,996 KB
testcase_09 WA -
testcase_10 AC 131 ms
56,092 KB
testcase_11 AC 126 ms
55,832 KB
testcase_12 AC 129 ms
55,724 KB
testcase_13 AC 131 ms
56,396 KB
testcase_14 AC 130 ms
56,004 KB
testcase_15 AC 132 ms
55,724 KB
testcase_16 AC 122 ms
55,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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 sum = 0;
	    
	    // 必要な豆の総数
	    for(int i = 0; i < f; i++) {
	        sum += sc.nextInt();
	    }
	    
	    // 準備した豆の合計数
	    int num = k * n;
	    
	    if(num > sum) {
	        System.out.println(num - sum);
	    }else{
	        System.out.println("-1");
	    }
	    
	}
}

0