結果

問題 No.143 豆
ユーザー kuramukuramu
提出日時 2016-01-19 22:06:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 865 bytes
コンパイル時間 1,978 ms
コンパイル使用メモリ 72,184 KB
実行使用メモリ 49,776 KB
最終ジャッジ日時 2023-09-30 16:41:21
合計ジャッジ時間 3,611 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,476 KB
testcase_01 AC 45 ms
49,364 KB
testcase_02 AC 45 ms
49,644 KB
testcase_03 AC 45 ms
49,236 KB
testcase_04 AC 47 ms
49,248 KB
testcase_05 AC 45 ms
49,276 KB
testcase_06 AC 46 ms
49,204 KB
testcase_07 AC 46 ms
49,076 KB
testcase_08 AC 45 ms
49,280 KB
testcase_09 AC 45 ms
49,248 KB
testcase_10 AC 44 ms
49,776 KB
testcase_11 AC 45 ms
49,324 KB
testcase_12 AC 46 ms
49,144 KB
testcase_13 AC 46 ms
49,240 KB
testcase_14 AC 45 ms
49,152 KB
testcase_15 AC 47 ms
49,260 KB
testcase_16 AC 46 ms
49,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      
	      try {
	    	  String[] temps = stdReader.readLine().split(" ");
	    	  int k=Integer.parseInt(temps[0]);
	    	  int n=Integer.parseInt(temps[1]);
	    	  int f=Integer.parseInt(temps[2]);
	    	  int sumBeans = k*n;
	    	  String[] temps2 = stdReader.readLine().split(" ");
	    	  int sumAge = 0;
	    	  for(int i=0;i<temps2.length;i++){
	    		  sumAge+=Integer.parseInt(temps2[i]);
	    	  }
	    	  if(sumBeans-sumAge>=0){
	    		  System.out.println(sumBeans-sumAge);
	    	  }else{
	    		  System.out.println(-1);
	    	  }
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0