結果

問題 No.5 数字のブロック
ユーザー kuramukuramu
提出日時 2016-01-19 22:25:13
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 3,566 ms
コンパイル使用メモリ 75,040 KB
実行使用メモリ 55,928 KB
最終ジャッジ日時 2023-10-21 13:14:52
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
53,568 KB
testcase_01 AC 57 ms
53,576 KB
testcase_02 WA -
testcase_03 AC 93 ms
55,248 KB
testcase_04 AC 88 ms
54,564 KB
testcase_05 AC 111 ms
55,664 KB
testcase_06 AC 92 ms
55,144 KB
testcase_07 AC 84 ms
54,420 KB
testcase_08 AC 100 ms
55,908 KB
testcase_09 AC 67 ms
54,572 KB
testcase_10 AC 109 ms
55,368 KB
testcase_11 AC 88 ms
54,572 KB
testcase_12 AC 105 ms
55,856 KB
testcase_13 AC 99 ms
55,392 KB
testcase_14 AC 57 ms
53,576 KB
testcase_15 AC 56 ms
53,580 KB
testcase_16 AC 96 ms
55,600 KB
testcase_17 AC 106 ms
55,868 KB
testcase_18 AC 107 ms
55,432 KB
testcase_19 AC 107 ms
55,928 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 54 ms
52,448 KB
testcase_24 AC 56 ms
53,580 KB
testcase_25 AC 58 ms
53,608 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 77 ms
54,428 KB
testcase_30 AC 71 ms
54,576 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {

	public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      
	      try {
	    	  int L = Integer.parseInt(stdReader.readLine());
	    	  int N = Integer.parseInt(stdReader.readLine());
	    	  String[] temps = stdReader.readLine().split(" ");
	    	  int[] nums = new int[temps.length];
	    	  for(int i=0;i<temps.length;i++){
	    		  nums[i] = Integer.parseInt(temps[i]);
	    	  }
	    	  
	    	  Arrays.sort(nums);
	    	  int sum = 0;
	    	  int count = 0;
	    	  for(int i=0;i<nums.length;i++){
	    		  sum += nums[i];
	    		  if(sum>L){
	    			  System.out.println(count);
	    			  break;
	    		  }
	    		  count++;
	    	  }
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0