結果

問題 No.5 数字のブロック
ユーザー mos_13184925mos_13184925
提出日時 2018-06-18 14:24:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 284 ms / 5,000 ms
コード長 602 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 74,284 KB
実行使用メモリ 47,848 KB
最終ジャッジ日時 2024-04-29 09:54:56
合計ジャッジ時間 9,736 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,264 KB
testcase_01 AC 132 ms
41,180 KB
testcase_02 AC 131 ms
41,324 KB
testcase_03 AC 246 ms
46,752 KB
testcase_04 AC 226 ms
45,336 KB
testcase_05 AC 264 ms
47,460 KB
testcase_06 AC 237 ms
46,312 KB
testcase_07 AC 231 ms
45,864 KB
testcase_08 AC 245 ms
46,480 KB
testcase_09 AC 205 ms
43,484 KB
testcase_10 AC 260 ms
47,000 KB
testcase_11 AC 233 ms
45,792 KB
testcase_12 AC 255 ms
46,576 KB
testcase_13 AC 251 ms
46,376 KB
testcase_14 AC 148 ms
41,628 KB
testcase_15 AC 158 ms
41,656 KB
testcase_16 AC 259 ms
46,768 KB
testcase_17 AC 274 ms
47,256 KB
testcase_18 AC 277 ms
47,580 KB
testcase_19 AC 284 ms
47,848 KB
testcase_20 AC 128 ms
41,224 KB
testcase_21 AC 131 ms
41,396 KB
testcase_22 AC 128 ms
41,292 KB
testcase_23 AC 130 ms
41,240 KB
testcase_24 AC 168 ms
41,788 KB
testcase_25 AC 171 ms
42,056 KB
testcase_26 AC 129 ms
41,204 KB
testcase_27 AC 132 ms
41,048 KB
testcase_28 AC 134 ms
41,172 KB
testcase_29 AC 226 ms
45,740 KB
testcase_30 AC 208 ms
43,728 KB
testcase_31 AC 131 ms
41,232 KB
testcase_32 AC 133 ms
41,288 KB
testcase_33 AC 130 ms
41,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    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 < W.length; i++) {
            W[i] = sc.nextInt();
        }
        Arrays.sort(W);
        int ans = 0;
        int n = 0;
        for(int i = 0; i < W.length; i++) {
            n += W[i];
            if(n > L) {
                break;
            };
            ans ++;
        }
        System.out.println(ans);
    }
}
0