結果

問題 No.5 数字のブロック
ユーザー kuramukuramu
提出日時 2016-01-19 22:29:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 926 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 75,396 KB
実行使用メモリ 40,224 KB
最終ジャッジ日時 2024-04-29 06:48:50
合計ジャッジ時間 5,624 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
37,108 KB
testcase_01 AC 52 ms
37,004 KB
testcase_02 AC 52 ms
36,932 KB
testcase_03 AC 82 ms
38,440 KB
testcase_04 AC 80 ms
38,564 KB
testcase_05 AC 102 ms
39,712 KB
testcase_06 AC 90 ms
38,292 KB
testcase_07 AC 80 ms
38,184 KB
testcase_08 AC 99 ms
38,920 KB
testcase_09 AC 60 ms
36,752 KB
testcase_10 AC 90 ms
39,768 KB
testcase_11 AC 77 ms
38,436 KB
testcase_12 AC 85 ms
38,544 KB
testcase_13 AC 92 ms
39,016 KB
testcase_14 AC 52 ms
36,844 KB
testcase_15 AC 53 ms
37,164 KB
testcase_16 AC 102 ms
39,340 KB
testcase_17 AC 107 ms
39,080 KB
testcase_18 AC 104 ms
39,328 KB
testcase_19 AC 108 ms
40,224 KB
testcase_20 AC 52 ms
36,868 KB
testcase_21 AC 52 ms
36,908 KB
testcase_22 AC 53 ms
36,824 KB
testcase_23 AC 53 ms
36,700 KB
testcase_24 AC 53 ms
36,928 KB
testcase_25 AC 54 ms
37,124 KB
testcase_26 AC 52 ms
36,640 KB
testcase_27 AC 52 ms
37,096 KB
testcase_28 AC 52 ms
36,736 KB
testcase_29 AC 74 ms
38,284 KB
testcase_30 AC 61 ms
37,516 KB
testcase_31 AC 52 ms
36,800 KB
testcase_32 AC 52 ms
36,844 KB
testcase_33 AC 54 ms
36,856 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