結果

問題 No.5 数字のブロック
ユーザー mos_13184925mos_13184925
提出日時 2018-06-18 14:15:27
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 588 bytes
コンパイル時間 2,918 ms
コンパイル使用メモリ 71,436 KB
実行使用メモリ 60,784 KB
最終ジャッジ日時 2023-09-13 06:45:45
合計ジャッジ時間 9,726 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,124 KB
testcase_01 AC 120 ms
55,888 KB
testcase_02 AC 119 ms
55,600 KB
testcase_03 AC 229 ms
59,352 KB
testcase_04 AC 214 ms
59,160 KB
testcase_05 AC 239 ms
60,240 KB
testcase_06 AC 228 ms
59,484 KB
testcase_07 AC 214 ms
59,168 KB
testcase_08 AC 216 ms
59,820 KB
testcase_09 AC 194 ms
58,876 KB
testcase_10 AC 242 ms
60,116 KB
testcase_11 AC 213 ms
59,128 KB
testcase_12 AC 232 ms
59,808 KB
testcase_13 AC 236 ms
59,840 KB
testcase_14 AC 134 ms
56,148 KB
testcase_15 AC 142 ms
56,148 KB
testcase_16 AC 241 ms
59,956 KB
testcase_17 AC 252 ms
59,996 KB
testcase_18 AC 253 ms
60,784 KB
testcase_19 AC 254 ms
60,192 KB
testcase_20 RE -
testcase_21 AC 122 ms
56,256 KB
testcase_22 AC 121 ms
55,872 KB
testcase_23 AC 121 ms
56,116 KB
testcase_24 AC 147 ms
56,400 KB
testcase_25 AC 168 ms
56,252 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 208 ms
59,188 KB
testcase_30 AC 195 ms
58,812 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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