結果

問題 No.5 数字のブロック
ユーザー S1ho
提出日時 2017-02-19 16:11:44
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 695 bytes
コンパイル時間 4,575 ms
コンパイル使用メモリ 76,812 KB
実行使用メモリ 54,384 KB
最終ジャッジ日時 2024-12-30 05:09:18
合計ジャッジ時間 13,357 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Box {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        int l = scanner.nextInt();
        int n = scanner.nextInt();
        
        ArrayList<Integer> width = new ArrayList();
        
        for(int i=0;i<n;i++){
            width.add(scanner.nextInt());
        }
        
        Collections.sort(width);
        
        int sum = 0;
        int count = 0;
        
        while(sum <= l){
            sum += width.get(count);
            count++;
        }
        
        System.out.println(count-1);
    }
    
}
0