結果

問題 No.5 数字のブロック
ユーザー hj5ln8kbDM8t2fFhj5ln8kbDM8t2fF
提出日時 2019-06-16 15:43:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 305 ms / 5,000 ms
コード長 1,102 bytes
コンパイル時間 2,495 ms
コンパイル使用メモリ 80,012 KB
実行使用メモリ 48,100 KB
最終ジャッジ日時 2024-05-03 06:16:27
合計ジャッジ時間 10,359 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,348 KB
testcase_01 AC 131 ms
41,128 KB
testcase_02 AC 135 ms
41,572 KB
testcase_03 AC 266 ms
47,116 KB
testcase_04 AC 240 ms
46,072 KB
testcase_05 AC 270 ms
46,936 KB
testcase_06 AC 241 ms
47,104 KB
testcase_07 AC 233 ms
45,540 KB
testcase_08 AC 252 ms
47,060 KB
testcase_09 AC 208 ms
43,384 KB
testcase_10 AC 286 ms
48,100 KB
testcase_11 AC 241 ms
45,764 KB
testcase_12 AC 257 ms
47,176 KB
testcase_13 AC 270 ms
47,176 KB
testcase_14 AC 144 ms
41,336 KB
testcase_15 AC 165 ms
41,548 KB
testcase_16 AC 279 ms
47,492 KB
testcase_17 AC 298 ms
47,648 KB
testcase_18 AC 285 ms
47,604 KB
testcase_19 AC 305 ms
47,428 KB
testcase_20 AC 139 ms
41,368 KB
testcase_21 AC 133 ms
41,620 KB
testcase_22 AC 138 ms
41,348 KB
testcase_23 AC 128 ms
41,208 KB
testcase_24 AC 177 ms
42,140 KB
testcase_25 AC 179 ms
41,964 KB
testcase_26 AC 131 ms
41,216 KB
testcase_27 AC 124 ms
40,124 KB
testcase_28 AC 118 ms
40,184 KB
testcase_29 AC 231 ms
46,104 KB
testcase_30 AC 209 ms
43,592 KB
testcase_31 AC 133 ms
41,600 KB
testcase_32 AC 137 ms
41,520 KB
testcase_33 AC 134 ms
41,012 KB
権限があれば一括ダウンロードができます

ソースコード

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