結果

問題 No.5 数字のブロック
ユーザー mobius_bkstmobius_bkst
提出日時 2015-04-22 23:15:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 981 bytes
コンパイル時間 3,502 ms
コンパイル使用メモリ 73,608 KB
実行使用メモリ 53,244 KB
最終ジャッジ日時 2023-09-18 08:23:07
合計ジャッジ時間 7,397 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,620 KB
testcase_01 AC 46 ms
49,276 KB
testcase_02 WA -
testcase_03 AC 75 ms
52,176 KB
testcase_04 AC 66 ms
51,264 KB
testcase_05 WA -
testcase_06 AC 76 ms
52,600 KB
testcase_07 AC 67 ms
51,236 KB
testcase_08 AC 78 ms
52,724 KB
testcase_09 AC 58 ms
51,024 KB
testcase_10 AC 94 ms
52,800 KB
testcase_11 AC 64 ms
52,220 KB
testcase_12 AC 72 ms
51,944 KB
testcase_13 AC 86 ms
52,344 KB
testcase_14 AC 47 ms
49,400 KB
testcase_15 WA -
testcase_16 AC 94 ms
52,788 KB
testcase_17 AC 92 ms
52,684 KB
testcase_18 AC 82 ms
52,728 KB
testcase_19 AC 98 ms
53,244 KB
testcase_20 AC 44 ms
49,272 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 44 ms
49,780 KB
testcase_24 AC 46 ms
49,400 KB
testcase_25 AC 49 ms
49,584 KB
testcase_26 AC 44 ms
49,352 KB
testcase_27 AC 45 ms
49,536 KB
testcase_28 AC 45 ms
49,264 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 44 ms
49,572 KB
testcase_32 AC 44 ms
49,212 KB
testcase_33 AC 45 ms
49,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No005 {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            int L = Integer.parseInt(br.readLine());
            int N = Integer.parseInt(br.readLine());
            String[] WStrArray = br.readLine().split(" ");

            int[] W = new int[N];
            for (int i = 0; i < N; i++) {
                W[i] = Integer.parseInt(WStrArray[i]);
            }
            Arrays.sort(W);

            int count = 0;
            for (int i = 0; i < N; i++) {
                L = L - W[i];
                if (L <= 0) {
                    break;
                }
                count++;
            }

            System.out.println(count);
        } catch (Exception e) {
            System.err.println("Error:" + e.getMessage());
        }
    }

}
0