結果

問題 No.5 数字のブロック
ユーザー Flere0114Flere0114
提出日時 2016-02-24 13:11:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 273 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 3,301 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 47,484 KB
最終ジャッジ日時 2024-04-29 06:59:19
合計ジャッジ時間 10,710 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,096 KB
testcase_01 AC 114 ms
40,108 KB
testcase_02 AC 129 ms
41,312 KB
testcase_03 AC 242 ms
46,784 KB
testcase_04 AC 221 ms
45,584 KB
testcase_05 AC 256 ms
46,452 KB
testcase_06 AC 224 ms
46,204 KB
testcase_07 AC 231 ms
45,760 KB
testcase_08 AC 233 ms
45,960 KB
testcase_09 AC 201 ms
43,756 KB
testcase_10 AC 253 ms
47,300 KB
testcase_11 AC 220 ms
46,196 KB
testcase_12 AC 244 ms
47,108 KB
testcase_13 AC 253 ms
46,572 KB
testcase_14 AC 138 ms
41,268 KB
testcase_15 AC 151 ms
41,416 KB
testcase_16 AC 256 ms
46,932 KB
testcase_17 AC 270 ms
47,288 KB
testcase_18 AC 263 ms
46,264 KB
testcase_19 AC 273 ms
47,484 KB
testcase_20 AC 128 ms
40,972 KB
testcase_21 AC 118 ms
40,104 KB
testcase_22 AC 128 ms
41,124 KB
testcase_23 AC 116 ms
39,864 KB
testcase_24 AC 160 ms
41,516 KB
testcase_25 AC 174 ms
41,852 KB
testcase_26 AC 128 ms
41,192 KB
testcase_27 AC 126 ms
41,272 KB
testcase_28 AC 127 ms
41,212 KB
testcase_29 AC 218 ms
45,544 KB
testcase_30 AC 202 ms
43,760 KB
testcase_31 AC 118 ms
40,088 KB
testcase_32 AC 116 ms
40,204 KB
testcase_33 AC 128 ms
41,216 KB
権限があれば一括ダウンロードができます

ソースコード

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;
            }
        }
        System.out.println(n);
    }
}
0