結果

問題 No.5 数字のブロック
ユーザー h_tyokinuhatah_tyokinuhata
提出日時 2015-12-19 23:31:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 523 bytes
コンパイル時間 2,584 ms
コンパイル使用メモリ 73,248 KB
実行使用メモリ 60,824 KB
最終ジャッジ日時 2023-08-11 14:27:23
合計ジャッジ時間 9,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,676 KB
testcase_01 AC 117 ms
55,676 KB
testcase_02 AC 116 ms
55,420 KB
testcase_03 AC 227 ms
59,872 KB
testcase_04 AC 212 ms
59,808 KB
testcase_05 AC 237 ms
60,320 KB
testcase_06 AC 217 ms
59,660 KB
testcase_07 AC 209 ms
59,060 KB
testcase_08 AC 219 ms
58,012 KB
testcase_09 AC 189 ms
58,236 KB
testcase_10 AC 258 ms
60,252 KB
testcase_11 AC 210 ms
59,872 KB
testcase_12 AC 220 ms
60,376 KB
testcase_13 AC 236 ms
60,404 KB
testcase_14 AC 128 ms
56,304 KB
testcase_15 AC 148 ms
56,160 KB
testcase_16 AC 237 ms
60,020 KB
testcase_17 AC 254 ms
60,820 KB
testcase_18 AC 254 ms
60,504 KB
testcase_19 AC 257 ms
60,824 KB
testcase_20 AC 115 ms
55,632 KB
testcase_21 AC 113 ms
55,920 KB
testcase_22 AC 117 ms
55,568 KB
testcase_23 AC 113 ms
55,836 KB
testcase_24 AC 134 ms
55,548 KB
testcase_25 AC 161 ms
56,580 KB
testcase_26 AC 112 ms
55,680 KB
testcase_27 AC 115 ms
55,932 KB
testcase_28 AC 115 ms
55,688 KB
testcase_29 AC 194 ms
59,036 KB
testcase_30 AC 192 ms
58,924 KB
testcase_31 AC 115 ms
55,668 KB
testcase_32 AC 115 ms
55,680 KB
testcase_33 AC 118 ms
55,780 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