結果

問題 No.5 数字のブロック
ユーザー 101000010101000010
提出日時 2017-05-17 16:26:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 222 ms / 5,000 ms
コード長 923 bytes
コンパイル時間 6,490 ms
コンパイル使用メモリ 72,844 KB
実行使用メモリ 59,892 KB
最終ジャッジ日時 2023-08-11 17:25:49
合計ジャッジ時間 12,373 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,656 KB
testcase_01 AC 124 ms
55,712 KB
testcase_02 AC 124 ms
55,632 KB
testcase_03 AC 202 ms
57,396 KB
testcase_04 AC 180 ms
56,388 KB
testcase_05 AC 213 ms
57,296 KB
testcase_06 AC 202 ms
57,344 KB
testcase_07 AC 197 ms
58,776 KB
testcase_08 AC 201 ms
57,644 KB
testcase_09 AC 165 ms
55,612 KB
testcase_10 AC 211 ms
57,480 KB
testcase_11 AC 193 ms
57,168 KB
testcase_12 AC 198 ms
57,756 KB
testcase_13 AC 208 ms
57,384 KB
testcase_14 AC 126 ms
55,876 KB
testcase_15 AC 126 ms
55,420 KB
testcase_16 AC 210 ms
57,592 KB
testcase_17 AC 217 ms
57,640 KB
testcase_18 AC 213 ms
57,676 KB
testcase_19 AC 222 ms
59,892 KB
testcase_20 AC 124 ms
55,416 KB
testcase_21 AC 128 ms
55,400 KB
testcase_22 AC 126 ms
55,856 KB
testcase_23 AC 125 ms
55,776 KB
testcase_24 AC 135 ms
55,876 KB
testcase_25 AC 140 ms
55,904 KB
testcase_26 AC 125 ms
55,580 KB
testcase_27 AC 124 ms
55,872 KB
testcase_28 AC 126 ms
55,852 KB
testcase_29 AC 179 ms
55,748 KB
testcase_30 AC 165 ms
57,832 KB
testcase_31 AC 124 ms
55,732 KB
testcase_32 AC 124 ms
55,868 KB
testcase_33 AC 124 ms
55,588 KB
権限があれば一括ダウンロードができます

ソースコード

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(count == boxS.length)break;
        }
        return count;
    }
}
0