結果

問題 No.5 数字のブロック
ユーザー syusyu
提出日時 2020-08-25 21:01:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 1,797 ms
コンパイル使用メモリ 78,396 KB
実行使用メモリ 47,820 KB
最終ジャッジ日時 2024-04-24 04:48:02
合計ジャッジ時間 8,439 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
40,516 KB
testcase_01 AC 103 ms
39,960 KB
testcase_02 WA -
testcase_03 AC 226 ms
46,512 KB
testcase_04 AC 198 ms
45,584 KB
testcase_05 AC 230 ms
46,468 KB
testcase_06 AC 203 ms
46,324 KB
testcase_07 AC 198 ms
45,488 KB
testcase_08 AC 207 ms
46,224 KB
testcase_09 AC 176 ms
43,616 KB
testcase_10 AC 224 ms
47,000 KB
testcase_11 AC 184 ms
45,628 KB
testcase_12 AC 212 ms
46,628 KB
testcase_13 AC 229 ms
46,964 KB
testcase_14 AC 126 ms
42,120 KB
testcase_15 AC 146 ms
41,340 KB
testcase_16 AC 229 ms
46,348 KB
testcase_17 AC 239 ms
47,100 KB
testcase_18 AC 238 ms
47,084 KB
testcase_19 AC 255 ms
47,820 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 101 ms
40,516 KB
testcase_24 AC 142 ms
41,744 KB
testcase_25 AC 157 ms
42,124 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 198 ms
45,556 KB
testcase_30 AC 186 ms
43,660 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
            count++;
            if(boxWidth<0){
                break;
            }
        }
        System.out.println(count-1);
    }
}
0