結果

問題 No.5 数字のブロック
ユーザー S1hoS1ho
提出日時 2017-02-19 16:11:44
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 695 bytes
コンパイル時間 3,336 ms
コンパイル使用メモリ 79,160 KB
実行使用メモリ 60,712 KB
最終ジャッジ日時 2023-08-28 19:13:59
合計ジャッジ時間 10,595 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,704 KB
testcase_01 AC 119 ms
55,528 KB
testcase_02 RE -
testcase_03 AC 237 ms
59,884 KB
testcase_04 AC 216 ms
59,876 KB
testcase_05 AC 251 ms
60,328 KB
testcase_06 AC 224 ms
59,036 KB
testcase_07 AC 216 ms
59,608 KB
testcase_08 AC 230 ms
59,408 KB
testcase_09 AC 197 ms
58,416 KB
testcase_10 AC 260 ms
60,276 KB
testcase_11 AC 216 ms
59,432 KB
testcase_12 AC 235 ms
59,980 KB
testcase_13 AC 243 ms
59,812 KB
testcase_14 AC 132 ms
56,452 KB
testcase_15 AC 141 ms
56,536 KB
testcase_16 AC 248 ms
60,572 KB
testcase_17 AC 262 ms
60,520 KB
testcase_18 AC 264 ms
60,468 KB
testcase_19 AC 269 ms
60,712 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 117 ms
56,244 KB
testcase_24 AC 153 ms
55,428 KB
testcase_25 AC 173 ms
54,220 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 205 ms
59,604 KB
testcase_30 AC 198 ms
58,912 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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