結果

問題 No.143 豆
ユーザー takutakutakutaku
提出日時 2020-09-16 16:51:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 607 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 71,476 KB
実行使用メモリ 57,160 KB
最終ジャッジ日時 2023-09-30 17:56:46
合計ジャッジ時間 6,075 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,536 KB
testcase_01 AC 136 ms
55,792 KB
testcase_02 AC 132 ms
55,652 KB
testcase_03 AC 138 ms
55,364 KB
testcase_04 AC 135 ms
55,668 KB
testcase_05 AC 140 ms
55,672 KB
testcase_06 AC 136 ms
55,796 KB
testcase_07 AC 137 ms
55,920 KB
testcase_08 AC 136 ms
55,332 KB
testcase_09 AC 136 ms
57,160 KB
testcase_10 AC 134 ms
55,616 KB
testcase_11 AC 139 ms
55,680 KB
testcase_12 AC 134 ms
55,716 KB
testcase_13 AC 137 ms
56,104 KB
testcase_14 AC 139 ms
55,356 KB
testcase_15 AC 138 ms
55,796 KB
testcase_16 AC 127 ms
55,640 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