結果

問題 No.5 数字のブロック
ユーザー 101000010101000010
提出日時 2017-05-17 16:25:08
言語 Java19
(openjdk 21)
結果
RE  
実行時間 -
コード長 915 bytes
コンパイル時間 3,832 ms
コンパイル使用メモリ 75,100 KB
実行使用メモリ 59,048 KB
最終ジャッジ日時 2023-10-17 23:54:36
合計ジャッジ時間 10,218 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,200 KB
testcase_01 AC 128 ms
57,520 KB
testcase_02 AC 132 ms
57,432 KB
testcase_03 AC 198 ms
58,416 KB
testcase_04 AC 169 ms
57,948 KB
testcase_05 AC 198 ms
58,448 KB
testcase_06 AC 192 ms
58,168 KB
testcase_07 AC 190 ms
58,036 KB
testcase_08 AC 190 ms
58,148 KB
testcase_09 AC 171 ms
57,484 KB
testcase_10 AC 210 ms
58,484 KB
testcase_11 AC 169 ms
57,528 KB
testcase_12 AC 194 ms
58,116 KB
testcase_13 AC 199 ms
58,540 KB
testcase_14 AC 125 ms
57,540 KB
testcase_15 AC 128 ms
57,628 KB
testcase_16 AC 201 ms
58,488 KB
testcase_17 AC 204 ms
59,004 KB
testcase_18 AC 197 ms
58,500 KB
testcase_19 AC 199 ms
59,048 KB
testcase_20 RE -
testcase_21 AC 125 ms
57,188 KB
testcase_22 AC 128 ms
57,200 KB
testcase_23 AC 122 ms
57,248 KB
testcase_24 AC 137 ms
57,852 KB
testcase_25 AC 140 ms
57,760 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 177 ms
57,664 KB
testcase_30 AC 174 ms
57,712 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++;
            if(capaBox == 0)break;
        }
        return count;
    }
}
0