結果

問題 No.5 数字のブロック
ユーザー 101000010
提出日時 2017-05-17 16:25:08
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 915 bytes
コンパイル時間 3,019 ms
コンパイル使用メモリ 76,376 KB
実行使用メモリ 56,184 KB
最終ジャッジ日時 2024-09-17 20:59:39
合計ジャッジ時間 8,797 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 RE * 7
権限があれば一括ダウンロードができます

ソースコード

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