結果

問題 No.5 数字のブロック
ユーザー kuramukuramu
提出日時 2016-01-19 22:29:49
言語 Java19
(openjdk 21)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 926 bytes
コンパイル時間 4,185 ms
コンパイル使用メモリ 72,596 KB
実行使用メモリ 52,812 KB
最終ジャッジ日時 2023-08-11 14:33:37
合計ジャッジ時間 6,399 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,148 KB
testcase_01 AC 44 ms
49,068 KB
testcase_02 AC 42 ms
49,480 KB
testcase_03 AC 72 ms
51,560 KB
testcase_04 AC 65 ms
51,748 KB
testcase_05 AC 89 ms
52,548 KB
testcase_06 AC 76 ms
52,620 KB
testcase_07 AC 67 ms
51,492 KB
testcase_08 AC 69 ms
52,484 KB
testcase_09 AC 55 ms
50,480 KB
testcase_10 AC 77 ms
50,032 KB
testcase_11 AC 66 ms
51,752 KB
testcase_12 AC 80 ms
52,552 KB
testcase_13 AC 79 ms
52,732 KB
testcase_14 AC 44 ms
49,248 KB
testcase_15 AC 46 ms
49,252 KB
testcase_16 AC 90 ms
52,620 KB
testcase_17 AC 91 ms
52,148 KB
testcase_18 AC 90 ms
52,408 KB
testcase_19 AC 94 ms
52,812 KB
testcase_20 AC 43 ms
49,300 KB
testcase_21 AC 43 ms
49,144 KB
testcase_22 AC 43 ms
49,116 KB
testcase_23 AC 42 ms
49,376 KB
testcase_24 AC 46 ms
49,572 KB
testcase_25 AC 49 ms
49,696 KB
testcase_26 AC 42 ms
49,248 KB
testcase_27 AC 43 ms
49,308 KB
testcase_28 AC 43 ms
49,304 KB
testcase_29 AC 62 ms
51,180 KB
testcase_30 AC 57 ms
50,408 KB
testcase_31 AC 43 ms
49,060 KB
testcase_32 AC 43 ms
51,056 KB
testcase_33 AC 44 ms
49,376 KB
権限があれば一括ダウンロードができます

ソースコード

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){
	    			  break;
	    		  }
	    		  count++;
	    	  }
			  System.out.println(count);
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0