結果

問題 No.5 数字のブロック
ユーザー mastersatoshimastersatoshi
提出日時 2015-08-01 11:53:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 2,734 ms
コンパイル使用メモリ 73,220 KB
実行使用メモリ 53,548 KB
最終ジャッジ日時 2023-08-11 08:36:02
合計ジャッジ時間 5,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,580 KB
testcase_01 AC 44 ms
49,520 KB
testcase_02 AC 44 ms
49,592 KB
testcase_03 AC 92 ms
52,628 KB
testcase_04 AC 76 ms
51,964 KB
testcase_05 AC 94 ms
53,264 KB
testcase_06 AC 78 ms
52,336 KB
testcase_07 AC 77 ms
51,844 KB
testcase_08 AC 88 ms
52,804 KB
testcase_09 AC 66 ms
51,700 KB
testcase_10 AC 95 ms
52,772 KB
testcase_11 AC 74 ms
52,088 KB
testcase_12 AC 87 ms
52,492 KB
testcase_13 AC 95 ms
52,824 KB
testcase_14 AC 46 ms
49,428 KB
testcase_15 AC 48 ms
50,008 KB
testcase_16 AC 97 ms
52,820 KB
testcase_17 AC 109 ms
53,068 KB
testcase_18 AC 97 ms
53,548 KB
testcase_19 AC 110 ms
52,848 KB
testcase_20 AC 44 ms
49,724 KB
testcase_21 AC 45 ms
49,468 KB
testcase_22 AC 43 ms
49,584 KB
testcase_23 AC 44 ms
47,604 KB
testcase_24 AC 49 ms
49,824 KB
testcase_25 AC 52 ms
49,524 KB
testcase_26 AC 45 ms
49,472 KB
testcase_27 AC 44 ms
49,700 KB
testcase_28 AC 44 ms
49,660 KB
testcase_29 AC 77 ms
51,992 KB
testcase_30 AC 63 ms
51,032 KB
testcase_31 AC 44 ms
49,708 KB
testcase_32 AC 43 ms
49,480 KB
testcase_33 AC 44 ms
49,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int L = Integer.parseInt(br.readLine());
        int N = Integer.parseInt(br.readLine());

        String[] strW = br.readLine().split(" ");

        ArrayList<Integer> W = new ArrayList();

        int sum = 0;
        for (int i = 0; i < strW.length; i++) {
            W.add(Integer.parseInt(strW[i]));
        }

        W.sort(null);

        int i = 0;
        for (; i < W.size(); i++) {
            int tmpW = W.get(i);
            if (L >= tmpW) {
                L -= tmpW;
            } else {
                break;
            }
        }

        System.out.println(i);
    }
}
0