結果

問題 No.5 数字のブロック
ユーザー sasakkisasakki
提出日時 2016-03-09 15:05:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 453 bytes
コンパイル時間 2,206 ms
コンパイル使用メモリ 74,052 KB
実行使用メモリ 47,740 KB
最終ジャッジ日時 2024-04-29 07:01:12
合計ジャッジ時間 9,557 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,344 KB
testcase_01 AC 117 ms
41,360 KB
testcase_02 AC 129 ms
40,916 KB
testcase_03 AC 247 ms
46,064 KB
testcase_04 AC 223 ms
45,908 KB
testcase_05 AC 255 ms
46,532 KB
testcase_06 AC 237 ms
45,940 KB
testcase_07 AC 224 ms
46,172 KB
testcase_08 AC 235 ms
46,648 KB
testcase_09 AC 199 ms
43,588 KB
testcase_10 AC 249 ms
47,400 KB
testcase_11 AC 224 ms
46,352 KB
testcase_12 AC 247 ms
46,920 KB
testcase_13 AC 251 ms
47,020 KB
testcase_14 AC 143 ms
41,712 KB
testcase_15 AC 156 ms
41,412 KB
testcase_16 AC 252 ms
46,540 KB
testcase_17 AC 271 ms
47,572 KB
testcase_18 AC 272 ms
47,128 KB
testcase_19 AC 262 ms
47,740 KB
testcase_20 AC 133 ms
41,564 KB
testcase_21 AC 130 ms
41,412 KB
testcase_22 AC 132 ms
41,164 KB
testcase_23 AC 130 ms
40,904 KB
testcase_24 AC 165 ms
41,436 KB
testcase_25 AC 175 ms
42,236 KB
testcase_26 AC 128 ms
41,320 KB
testcase_27 AC 130 ms
41,556 KB
testcase_28 AC 130 ms
41,264 KB
testcase_29 AC 227 ms
45,788 KB
testcase_30 AC 216 ms
44,116 KB
testcase_31 AC 130 ms
41,516 KB
testcase_32 AC 130 ms
41,212 KB
testcase_33 AC 131 ms
41,512 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