結果

問題 No.5 数字のブロック
ユーザー Flere0114Flere0114
提出日時 2016-02-24 13:07:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 3,906 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 62,052 KB
最終ジャッジ日時 2023-10-23 19:34:52
合計ジャッジ時間 11,461 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,608 KB
testcase_01 AC 130 ms
57,452 KB
testcase_02 WA -
testcase_03 AC 241 ms
61,328 KB
testcase_04 AC 223 ms
60,496 KB
testcase_05 AC 252 ms
61,536 KB
testcase_06 AC 232 ms
60,496 KB
testcase_07 AC 225 ms
60,500 KB
testcase_08 AC 241 ms
61,008 KB
testcase_09 AC 205 ms
59,716 KB
testcase_10 AC 253 ms
60,004 KB
testcase_11 AC 224 ms
60,832 KB
testcase_12 AC 246 ms
61,192 KB
testcase_13 AC 266 ms
61,404 KB
testcase_14 AC 144 ms
57,844 KB
testcase_15 AC 155 ms
57,744 KB
testcase_16 AC 257 ms
61,264 KB
testcase_17 AC 264 ms
61,784 KB
testcase_18 AC 261 ms
62,052 KB
testcase_19 AC 272 ms
61,996 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 130 ms
57,648 KB
testcase_24 AC 161 ms
57,756 KB
testcase_25 AC 182 ms
57,784 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 213 ms
60,556 KB
testcase_30 AC 204 ms
60,056 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l, n, sum = 0, ans = 0;
        l = sc.nextInt();
        n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }
        Arrays.sort(w);

        for (int i = 0; i < n; i++) {
            sum += w[i];
            if(sum > l){
                System.out.println(i);
                return;
            }
        }
    }
}
0