結果

問題 No.5 数字のブロック
ユーザー hippolover02hippolover02
提出日時 2022-07-23 10:43:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 71,696 KB
実行使用メモリ 60,728 KB
最終ジャッジ日時 2023-09-18 05:11:09
合計ジャッジ時間 9,721 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,088 KB
testcase_01 AC 123 ms
56,352 KB
testcase_02 WA -
testcase_03 AC 216 ms
59,780 KB
testcase_04 AC 206 ms
59,256 KB
testcase_05 WA -
testcase_06 AC 221 ms
59,092 KB
testcase_07 AC 210 ms
59,116 KB
testcase_08 AC 221 ms
59,456 KB
testcase_09 AC 193 ms
58,152 KB
testcase_10 AC 245 ms
59,840 KB
testcase_11 AC 212 ms
59,408 KB
testcase_12 AC 236 ms
59,904 KB
testcase_13 AC 243 ms
60,172 KB
testcase_14 AC 140 ms
58,084 KB
testcase_15 WA -
testcase_16 AC 246 ms
60,348 KB
testcase_17 AC 254 ms
60,408 KB
testcase_18 AC 246 ms
60,000 KB
testcase_19 AC 257 ms
60,228 KB
testcase_20 AC 122 ms
55,860 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 123 ms
56,644 KB
testcase_24 AC 149 ms
56,388 KB
testcase_25 AC 180 ms
56,084 KB
testcase_26 AC 124 ms
56,112 KB
testcase_27 AC 123 ms
53,992 KB
testcase_28 AC 123 ms
56,284 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 123 ms
56,276 KB
testcase_32 AC 122 ms
55,768 KB
testcase_33 AC 125 ms
56,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int box = sc.nextInt();
        int num = sc.nextInt();
        int[] width = new int[num];
        
        for(int i=0; i<num; i++){
            width[i] = sc.nextInt();
        }
        Arrays.sort(width);
        int tmp = 0;
        int r = 0;
        
        for(int n : width){
            tmp += n;
            if(box > tmp){
                r++;
            } else {
                break;
            }
        }
        System.out.println(r);
    }
}
0