結果
問題 |
No.143 豆
|
ユーザー |
|
提出日時 | 2020-09-16 16:51:24 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 148 ms / 1,000 ms |
コード長 | 607 bytes |
コンパイル時間 | 2,370 ms |
コンパイル使用メモリ | 74,236 KB |
実行使用メモリ | 54,368 KB |
最終ジャッジ日時 | 2024-07-23 11:37:02 |
合計ジャッジ時間 | 5,716 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
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"); } } }