結果

問題 No.5 数字のブロック
ユーザー atkrymatkrym
提出日時 2016-10-13 12:30:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 291 ms / 5,000 ms
コード長 641 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 76,220 KB
実行使用メモリ 47,940 KB
最終ジャッジ日時 2024-04-29 08:11:56
合計ジャッジ時間 9,751 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,052 KB
testcase_01 AC 116 ms
40,372 KB
testcase_02 AC 115 ms
40,268 KB
testcase_03 AC 256 ms
46,300 KB
testcase_04 AC 226 ms
45,792 KB
testcase_05 AC 269 ms
46,792 KB
testcase_06 AC 243 ms
45,804 KB
testcase_07 AC 234 ms
46,064 KB
testcase_08 AC 245 ms
46,076 KB
testcase_09 AC 209 ms
43,612 KB
testcase_10 AC 279 ms
47,940 KB
testcase_11 AC 233 ms
45,652 KB
testcase_12 AC 258 ms
46,724 KB
testcase_13 AC 266 ms
46,972 KB
testcase_14 AC 147 ms
41,420 KB
testcase_15 AC 154 ms
41,452 KB
testcase_16 AC 271 ms
46,700 KB
testcase_17 AC 283 ms
47,588 KB
testcase_18 AC 284 ms
47,692 KB
testcase_19 AC 291 ms
47,424 KB
testcase_20 AC 132 ms
41,164 KB
testcase_21 AC 127 ms
41,304 KB
testcase_22 AC 114 ms
39,908 KB
testcase_23 AC 122 ms
40,108 KB
testcase_24 AC 156 ms
41,572 KB
testcase_25 AC 187 ms
42,124 KB
testcase_26 AC 133 ms
41,120 KB
testcase_27 AC 127 ms
41,156 KB
testcase_28 AC 126 ms
40,712 KB
testcase_29 AC 233 ms
46,116 KB
testcase_30 AC 210 ms
43,592 KB
testcase_31 AC 117 ms
40,052 KB
testcase_32 AC 115 ms
40,228 KB
testcase_33 AC 116 ms
40,116 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