結果

問題 No.143 豆
ユーザー NaruYNaruY
提出日時 2016-10-22 15:26:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 1,000 ms
コード長 754 bytes
コンパイル時間 3,028 ms
コンパイル使用メモリ 73,048 KB
実行使用メモリ 56,036 KB
最終ジャッジ日時 2023-09-30 16:53:15
合計ジャッジ時間 5,152 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,264 KB
testcase_01 AC 130 ms
55,532 KB
testcase_02 AC 129 ms
55,720 KB
testcase_03 AC 129 ms
55,764 KB
testcase_04 AC 129 ms
55,760 KB
testcase_05 AC 130 ms
56,036 KB
testcase_06 AC 129 ms
55,624 KB
testcase_07 AC 130 ms
55,376 KB
testcase_08 AC 130 ms
55,836 KB
testcase_09 AC 129 ms
55,272 KB
testcase_10 AC 130 ms
56,008 KB
testcase_11 AC 126 ms
55,516 KB
testcase_12 AC 146 ms
55,636 KB
testcase_13 AC 132 ms
55,668 KB
testcase_14 AC 132 ms
53,912 KB
testcase_15 AC 130 ms
55,636 KB
testcase_16 AC 121 ms
55,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    	
    	int K = sc.nextInt();
    	int N = sc.nextInt();
    	int F = sc.nextInt();
    	int S = 0;
    	
    	int af[] = new int[F+1];
    	
    	for (int i = 1 ; i <= F ; i++){
    		af[i] = sc.nextInt();
    	}
    	
    	for (int j = 1 ; j <= F ; j++){
    		S += af[j];
    	}
    	
    	if (K*N >= S){
    		System.out.println(K*N - S);
    	}
    	else {
    		System.out.println("-1");
    	}
    	
    	
    	
    }	
}
    
   
0