結果

問題 No.5 数字のブロック
ユーザー hj5ln8kbDM8t2fFhj5ln8kbDM8t2fF
提出日時 2019-06-16 15:34:26
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 966 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 75,492 KB
実行使用メモリ 46,340 KB
最終ジャッジ日時 2024-05-03 06:02:43
合計ジャッジ時間 7,593 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc1 = new Scanner(System.in);
        Scanner sc2 = new Scanner(System.in);
        Scanner sc3 = new Scanner(System.in);
        List <Integer> W = new ArrayList<Integer>();

        //大きな箱の幅
        int L = sc1.nextInt();
        
        //ブロックの数
        int N = sc2.nextInt();
        
        //各ブロックの幅を格納
        for(int i=0;i<N;i++ ){
            int input = sc3.nextInt();
            W.add(input);
        }
        
        //昇順でsort
        Collections.sort(W);
        
        //大きな箱の中に、小さい箱を入れていく
        int total = 0;
        int kosu = 0;
        for(int j=0;j<=kosu;j++){
            int num = W.get(j);
            total = total + num;
            if(total > L){
                break;
            }
        }
        System.out.println(kosu);
        
    }
}
0