結果

問題 No.5 数字のブロック
ユーザー GrenacheGrenache
提出日時 2015-06-30 20:22:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 275 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 3,610 ms
コンパイル使用メモリ 75,484 KB
実行使用メモリ 47,560 KB
最終ジャッジ日時 2024-04-29 01:04:35
合計ジャッジ時間 10,797 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,448 KB
testcase_01 AC 127 ms
41,252 KB
testcase_02 AC 114 ms
39,856 KB
testcase_03 AC 238 ms
46,504 KB
testcase_04 AC 223 ms
45,716 KB
testcase_05 AC 255 ms
47,292 KB
testcase_06 AC 234 ms
46,216 KB
testcase_07 AC 221 ms
45,236 KB
testcase_08 AC 242 ms
46,716 KB
testcase_09 AC 201 ms
43,568 KB
testcase_10 AC 258 ms
47,468 KB
testcase_11 AC 232 ms
46,048 KB
testcase_12 AC 247 ms
46,548 KB
testcase_13 AC 255 ms
47,560 KB
testcase_14 AC 142 ms
41,504 KB
testcase_15 AC 153 ms
41,916 KB
testcase_16 AC 261 ms
46,616 KB
testcase_17 AC 275 ms
47,364 KB
testcase_18 AC 269 ms
47,404 KB
testcase_19 AC 269 ms
47,544 KB
testcase_20 AC 130 ms
41,176 KB
testcase_21 AC 131 ms
41,152 KB
testcase_22 AC 129 ms
41,312 KB
testcase_23 AC 132 ms
41,548 KB
testcase_24 AC 153 ms
41,864 KB
testcase_25 AC 177 ms
41,856 KB
testcase_26 AC 129 ms
40,652 KB
testcase_27 AC 129 ms
41,048 KB
testcase_28 AC 116 ms
39,852 KB
testcase_29 AC 223 ms
46,204 KB
testcase_30 AC 203 ms
43,960 KB
testcase_31 AC 116 ms
40,080 KB
testcase_32 AC 130 ms
41,416 KB
testcase_33 AC 131 ms
41,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder5 {

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

        int l = sc.nextInt();
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
        	w[i] = sc.nextInt();
        }
        
        Arrays.sort(w);
        int ret = 0;
        for (int i = 0; i < n && l >= w[i]; i++) {
        	l -= w[i];
        	ret++;
        }

        System.out.println(ret);
        
        sc.close();
    }
}
0