結果

問題 No.5 数字のブロック
ユーザー h_tyokinuhatah_tyokinuhata
提出日時 2015-12-19 23:31:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 304 ms / 5,000 ms
コード長 523 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 85,560 KB
実行使用メモリ 47,900 KB
最終ジャッジ日時 2024-04-29 06:43:14
合計ジャッジ時間 10,573 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,104 KB
testcase_01 AC 137 ms
41,072 KB
testcase_02 AC 136 ms
41,308 KB
testcase_03 AC 265 ms
46,852 KB
testcase_04 AC 239 ms
45,896 KB
testcase_05 AC 273 ms
46,932 KB
testcase_06 AC 256 ms
46,196 KB
testcase_07 AC 240 ms
45,592 KB
testcase_08 AC 255 ms
46,480 KB
testcase_09 AC 209 ms
43,660 KB
testcase_10 AC 289 ms
47,728 KB
testcase_11 AC 240 ms
46,124 KB
testcase_12 AC 259 ms
46,864 KB
testcase_13 AC 271 ms
46,280 KB
testcase_14 AC 152 ms
41,680 KB
testcase_15 AC 160 ms
41,736 KB
testcase_16 AC 273 ms
47,272 KB
testcase_17 AC 297 ms
47,728 KB
testcase_18 AC 296 ms
47,424 KB
testcase_19 AC 304 ms
47,900 KB
testcase_20 AC 134 ms
41,428 KB
testcase_21 AC 132 ms
41,096 KB
testcase_22 AC 128 ms
40,100 KB
testcase_23 AC 135 ms
41,284 KB
testcase_24 AC 170 ms
41,532 KB
testcase_25 AC 188 ms
41,812 KB
testcase_26 AC 133 ms
41,080 KB
testcase_27 AC 135 ms
41,084 KB
testcase_28 AC 136 ms
41,080 KB
testcase_29 AC 241 ms
45,912 KB
testcase_30 AC 216 ms
43,928 KB
testcase_31 AC 133 ms
40,880 KB
testcase_32 AC 137 ms
41,336 KB
testcase_33 AC 136 ms
41,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	ArrayList<Integer> W = new ArrayList<>();

    	int L = sc.nextInt();
    	int N = sc.nextInt();
    	for(int i = 0; i < N; i++) {
    		W.add(sc.nextInt());
    	}
    	Collections.sort(W);
    	int i = 0;
    	while(L >= 0 && i < N) {
   	   		L = L - W.get(i);
   	   		if(L >= 0) {
   	   			i++;
   	   		} else {
   	   			break;
   	   		}
    	}
    	System.out.println(i);
    }
}
0