結果

問題 No.5 数字のブロック
ユーザー GrenacheGrenache
提出日時 2015-06-30 20:22:55
言語 Java19
(openjdk 21)
結果
AC  
実行時間 257 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 3,979 ms
コンパイル使用メモリ 73,224 KB
実行使用メモリ 62,120 KB
最終ジャッジ日時 2023-08-11 08:31:38
合計ジャッジ時間 10,717 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,060 KB
testcase_01 AC 125 ms
55,696 KB
testcase_02 AC 124 ms
55,824 KB
testcase_03 AC 228 ms
59,648 KB
testcase_04 AC 213 ms
57,240 KB
testcase_05 AC 242 ms
59,868 KB
testcase_06 AC 223 ms
59,532 KB
testcase_07 AC 215 ms
59,132 KB
testcase_08 AC 234 ms
59,900 KB
testcase_09 AC 199 ms
59,152 KB
testcase_10 AC 255 ms
60,684 KB
testcase_11 AC 216 ms
59,860 KB
testcase_12 AC 237 ms
62,120 KB
testcase_13 AC 240 ms
59,728 KB
testcase_14 AC 137 ms
55,908 KB
testcase_15 AC 159 ms
55,728 KB
testcase_16 AC 247 ms
60,316 KB
testcase_17 AC 250 ms
60,132 KB
testcase_18 AC 257 ms
60,824 KB
testcase_19 AC 253 ms
60,324 KB
testcase_20 AC 125 ms
55,744 KB
testcase_21 AC 129 ms
55,764 KB
testcase_22 AC 122 ms
55,856 KB
testcase_23 AC 123 ms
55,792 KB
testcase_24 AC 150 ms
56,268 KB
testcase_25 AC 179 ms
56,336 KB
testcase_26 AC 127 ms
55,900 KB
testcase_27 AC 122 ms
55,748 KB
testcase_28 AC 122 ms
55,808 KB
testcase_29 AC 212 ms
59,364 KB
testcase_30 AC 201 ms
58,340 KB
testcase_31 AC 125 ms
55,752 KB
testcase_32 AC 125 ms
55,900 KB
testcase_33 AC 123 ms
55,704 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