結果

問題 No.5 数字のブロック
ユーザー mastersatoshimastersatoshi
提出日時 2015-08-01 11:53:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 75,796 KB
実行使用メモリ 40,112 KB
最終ジャッジ日時 2024-04-29 01:08:48
合計ジャッジ時間 5,512 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
36,256 KB
testcase_01 AC 45 ms
36,640 KB
testcase_02 AC 44 ms
36,880 KB
testcase_03 AC 78 ms
39,300 KB
testcase_04 AC 83 ms
38,448 KB
testcase_05 AC 89 ms
39,096 KB
testcase_06 AC 75 ms
38,696 KB
testcase_07 AC 74 ms
38,524 KB
testcase_08 AC 82 ms
38,736 KB
testcase_09 AC 60 ms
38,224 KB
testcase_10 AC 100 ms
40,112 KB
testcase_11 AC 74 ms
38,060 KB
testcase_12 AC 83 ms
39,384 KB
testcase_13 AC 86 ms
39,176 KB
testcase_14 AC 46 ms
36,840 KB
testcase_15 AC 48 ms
37,132 KB
testcase_16 AC 93 ms
39,524 KB
testcase_17 AC 106 ms
39,968 KB
testcase_18 AC 96 ms
39,440 KB
testcase_19 AC 110 ms
40,056 KB
testcase_20 AC 46 ms
36,620 KB
testcase_21 AC 46 ms
37,032 KB
testcase_22 AC 46 ms
36,644 KB
testcase_23 AC 46 ms
36,516 KB
testcase_24 AC 49 ms
36,720 KB
testcase_25 AC 47 ms
36,656 KB
testcase_26 AC 47 ms
36,732 KB
testcase_27 AC 47 ms
36,656 KB
testcase_28 AC 48 ms
36,624 KB
testcase_29 AC 83 ms
38,320 KB
testcase_30 AC 76 ms
38,052 KB
testcase_31 AC 47 ms
36,628 KB
testcase_32 AC 46 ms
37,036 KB
testcase_33 AC 45 ms
36,788 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