結果

問題 No.5 数字のブロック
ユーザー atkrymatkrym
提出日時 2016-10-13 12:33:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 297 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 77,112 KB
実行使用メモリ 47,828 KB
最終ジャッジ日時 2024-04-29 08:13:30
合計ジャッジ時間 10,152 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,120 KB
testcase_01 AC 133 ms
41,312 KB
testcase_02 AC 128 ms
41,260 KB
testcase_03 AC 256 ms
46,716 KB
testcase_04 AC 234 ms
46,020 KB
testcase_05 AC 277 ms
46,844 KB
testcase_06 AC 250 ms
46,360 KB
testcase_07 AC 233 ms
45,900 KB
testcase_08 AC 257 ms
46,464 KB
testcase_09 AC 221 ms
43,332 KB
testcase_10 AC 289 ms
47,044 KB
testcase_11 AC 245 ms
46,036 KB
testcase_12 AC 258 ms
46,340 KB
testcase_13 AC 267 ms
46,784 KB
testcase_14 AC 144 ms
41,408 KB
testcase_15 AC 163 ms
41,468 KB
testcase_16 AC 272 ms
46,744 KB
testcase_17 AC 281 ms
47,656 KB
testcase_18 AC 287 ms
47,712 KB
testcase_19 AC 297 ms
47,828 KB
testcase_20 AC 131 ms
41,172 KB
testcase_21 AC 132 ms
40,980 KB
testcase_22 AC 130 ms
41,252 KB
testcase_23 AC 118 ms
40,208 KB
testcase_24 AC 159 ms
41,864 KB
testcase_25 AC 184 ms
41,880 KB
testcase_26 AC 130 ms
41,140 KB
testcase_27 AC 131 ms
40,992 KB
testcase_28 AC 129 ms
41,068 KB
testcase_29 AC 232 ms
45,716 KB
testcase_30 AC 209 ms
43,832 KB
testcase_31 AC 118 ms
40,456 KB
testcase_32 AC 129 ms
40,972 KB
testcase_33 AC 128 ms
40,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int l = sc.nextInt();
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        
        Collections.sort(list);
        
        int sum = 0;
        int ret = 0;
        for (Integer i : list) {
            sum += i;
            if (sum > l) {
                break;
            }
            ret++;
        }
        
        System.out.println(ret);
    }
}
0