結果

問題 No.5 数字のブロック
ユーザー syusyu
提出日時 2020-08-25 22:56:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 262 ms / 5,000 ms
コード長 614 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 74,996 KB
実行使用メモリ 47,796 KB
最終ジャッジ日時 2024-04-24 04:56:49
合計ジャッジ時間 8,519 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
40,440 KB
testcase_01 AC 113 ms
41,372 KB
testcase_02 AC 109 ms
40,468 KB
testcase_03 AC 238 ms
46,636 KB
testcase_04 AC 194 ms
45,764 KB
testcase_05 AC 262 ms
46,880 KB
testcase_06 AC 221 ms
46,580 KB
testcase_07 AC 204 ms
45,836 KB
testcase_08 AC 210 ms
46,644 KB
testcase_09 AC 183 ms
43,684 KB
testcase_10 AC 233 ms
46,968 KB
testcase_11 AC 199 ms
45,956 KB
testcase_12 AC 215 ms
45,976 KB
testcase_13 AC 249 ms
46,660 KB
testcase_14 AC 125 ms
41,028 KB
testcase_15 AC 146 ms
42,036 KB
testcase_16 AC 242 ms
46,428 KB
testcase_17 AC 242 ms
47,464 KB
testcase_18 AC 240 ms
47,796 KB
testcase_19 AC 244 ms
47,756 KB
testcase_20 AC 97 ms
40,184 KB
testcase_21 AC 111 ms
41,064 KB
testcase_22 AC 112 ms
41,440 KB
testcase_23 AC 111 ms
41,320 KB
testcase_24 AC 145 ms
41,804 KB
testcase_25 AC 149 ms
41,848 KB
testcase_26 AC 110 ms
41,440 KB
testcase_27 AC 110 ms
41,152 KB
testcase_28 AC 110 ms
41,092 KB
testcase_29 AC 196 ms
45,728 KB
testcase_30 AC 181 ms
43,928 KB
testcase_31 AC 100 ms
40,288 KB
testcase_32 AC 100 ms
40,424 KB
testcase_33 AC 109 ms
41,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int boxWidth=sc.nextInt();
        int n=sc.nextInt();
        
        int[] blocks=new int[n];
        for(int i=0;i<n;i++){
            blocks[i]=sc.nextInt();
        }
        Arrays.sort(blocks);
        ///System.out.println(Arrays.toString(blocks));
        int count=0;
        for(int block:blocks){
            boxWidth-=block;
            if(boxWidth<0){
                break;
            }
            count++;
        }
        System.out.println(count);
    }
}
0