結果

問題 No.5 数字のブロック
ユーザー sasakkisasakki
提出日時 2016-03-09 15:05:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 262 ms / 5,000 ms
コード長 453 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 72,304 KB
実行使用メモリ 61,588 KB
最終ジャッジ日時 2023-08-11 14:47:09
合計ジャッジ時間 9,608 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,884 KB
testcase_01 AC 123 ms
55,864 KB
testcase_02 AC 123 ms
55,652 KB
testcase_03 AC 237 ms
60,224 KB
testcase_04 AC 203 ms
58,888 KB
testcase_05 AC 243 ms
60,248 KB
testcase_06 AC 214 ms
60,156 KB
testcase_07 AC 213 ms
59,280 KB
testcase_08 AC 226 ms
60,352 KB
testcase_09 AC 195 ms
58,444 KB
testcase_10 AC 240 ms
59,940 KB
testcase_11 AC 213 ms
59,624 KB
testcase_12 AC 236 ms
59,708 KB
testcase_13 AC 241 ms
61,588 KB
testcase_14 AC 138 ms
55,716 KB
testcase_15 AC 154 ms
55,884 KB
testcase_16 AC 239 ms
60,304 KB
testcase_17 AC 255 ms
60,616 KB
testcase_18 AC 258 ms
60,060 KB
testcase_19 AC 262 ms
60,780 KB
testcase_20 AC 123 ms
55,848 KB
testcase_21 AC 124 ms
56,184 KB
testcase_22 AC 122 ms
55,836 KB
testcase_23 AC 121 ms
56,232 KB
testcase_24 AC 143 ms
55,500 KB
testcase_25 AC 175 ms
55,876 KB
testcase_26 AC 120 ms
55,876 KB
testcase_27 AC 122 ms
55,772 KB
testcase_28 AC 122 ms
55,872 KB
testcase_29 AC 218 ms
58,836 KB
testcase_30 AC 191 ms
58,784 KB
testcase_31 AC 122 ms
55,784 KB
testcase_32 AC 122 ms
56,068 KB
testcase_33 AC 121 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

class Main{
    public static void main(String args[]){
	
	Scanner scan = new Scanner(System.in);

	int L = scan.nextInt();
	int N = scan.nextInt();

	int[] W = new int[N];

	for(int i = 0; i < N; i++){
	    W[i] = scan.nextInt();
	}

	Arrays.sort(W);

	int cnt = 0;

	for(int i = 0; i < N; i++){
	    L -= W[i];
	    if(L < 0){
		break;
	    }
	    cnt++;
	}

	System.out.println(cnt);

    }
    
}
0