結果

問題 No.5 数字のブロック
ユーザー hj5ln8kbDM8t2fF
提出日時 2019-06-16 15:34:26
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 966 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 75,132 KB
実行使用メモリ 58,648 KB
最終ジャッジ日時 2024-11-24 03:37:50
合計ジャッジ時間 7,479 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 12 RE * 22
権限があれば一括ダウンロードができます

ソースコード

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