結果

問題 No.5 数字のブロック
ユーザー 101000010101000010
提出日時 2017-05-17 16:22:39
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 880 bytes
コンパイル時間 3,481 ms
コンパイル使用メモリ 75,568 KB
実行使用メモリ 59,008 KB
最終ジャッジ日時 2023-10-17 23:54:21
合計ジャッジ時間 11,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,740 KB
testcase_01 AC 129 ms
57,180 KB
testcase_02 RE -
testcase_03 AC 201 ms
58,312 KB
testcase_04 AC 173 ms
57,708 KB
testcase_05 AC 207 ms
58,744 KB
testcase_06 AC 196 ms
58,196 KB
testcase_07 AC 189 ms
58,172 KB
testcase_08 AC 197 ms
58,500 KB
testcase_09 AC 177 ms
57,700 KB
testcase_10 AC 209 ms
58,636 KB
testcase_11 AC 191 ms
58,292 KB
testcase_12 AC 201 ms
58,212 KB
testcase_13 AC 207 ms
56,596 KB
testcase_14 AC 132 ms
57,636 KB
testcase_15 AC 136 ms
57,780 KB
testcase_16 AC 212 ms
58,420 KB
testcase_17 AC 215 ms
58,496 KB
testcase_18 AC 214 ms
59,008 KB
testcase_19 AC 215 ms
58,740 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 130 ms
57,500 KB
testcase_24 AC 136 ms
57,716 KB
testcase_25 AC 142 ms
57,384 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 171 ms
57,828 KB
testcase_30 AC 168 ms
57,892 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No005 {

    public static void main(String[] args) {
        int BOX_L_SIZE;
        int N;
        int[] BOX_S;
        
        Scanner sc = new Scanner(System.in);
        BOX_L_SIZE = Integer.parseInt(sc.nextLine());
        N = Integer.parseInt(sc.nextLine());
        BOX_S = new int[N];
        String str = sc.nextLine();
        String[] inputs = str.split(" ");
        for(int i=0; i<N; i++){
            BOX_S[i] = Integer.parseInt(inputs[i]);
        }
        
        System.out.println(countBox(BOX_L_SIZE, BOX_S));
    }
    static int countBox(int boxSize, int[] boxS){
        int count = 0;
        int capaBox = boxSize;
        
        Arrays.sort(boxS);
        while(boxS[count] <= capaBox){
            capaBox -= boxS[count];
            count++;
        }
        return count;
    }
}
0