結果

問題 No.143 豆
ユーザー NaruY
提出日時 2016-10-22 15:26:25
言語 Java
(openjdk 23)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 754 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 75,296 KB
実行使用メモリ 54,296 KB
最終ジャッジ日時 2024-07-23 10:37:49
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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