結果

問題 No.143 豆
ユーザー GBGB
提出日時 2018-04-09 13:18:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 581 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 72,604 KB
実行使用メモリ 56,024 KB
最終ジャッジ日時 2023-09-30 17:15:36
合計ジャッジ時間 4,745 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,332 KB
testcase_01 AC 122 ms
54,212 KB
testcase_02 AC 122 ms
55,644 KB
testcase_03 AC 122 ms
55,452 KB
testcase_04 AC 124 ms
55,412 KB
testcase_05 AC 122 ms
55,656 KB
testcase_06 AC 121 ms
56,024 KB
testcase_07 AC 121 ms
55,580 KB
testcase_08 AC 121 ms
55,416 KB
testcase_09 AC 121 ms
55,636 KB
testcase_10 AC 121 ms
55,996 KB
testcase_11 AC 118 ms
55,964 KB
testcase_12 AC 120 ms
55,468 KB
testcase_13 AC 121 ms
55,800 KB
testcase_14 AC 122 ms
55,636 KB
testcase_15 AC 123 ms
53,788 KB
testcase_16 AC 114 ms
55,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args) {

    Scanner scan=new Scanner(System.in);
    int k=Integer.parseInt(scan.next());
    int n=Integer.parseInt(scan.next());
    int f=Integer.parseInt(scan.next());
    int total=k*n;

    int[] array=new int[f];
    for(int i=0;i<array.length;i++){
      array[i]=Integer.parseInt(scan.next());
    }

    for(int i=0;i<array.length;i++){
      total-=array[i];
      if(total<0){
        System.out.println("-1");
        return;
      }
    }
    
    System.out.println(total);
  }
}
0