結果

問題 No.5 数字のブロック
ユーザー hippolover02hippolover02
提出日時 2022-07-23 10:44:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 256 ms / 5,000 ms
コード長 603 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 71,760 KB
実行使用メモリ 60,716 KB
最終ジャッジ日時 2023-09-18 05:12:52
合計ジャッジ時間 9,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,600 KB
testcase_01 AC 122 ms
56,112 KB
testcase_02 AC 121 ms
55,972 KB
testcase_03 AC 227 ms
59,224 KB
testcase_04 AC 215 ms
59,148 KB
testcase_05 AC 242 ms
60,620 KB
testcase_06 AC 228 ms
59,352 KB
testcase_07 AC 217 ms
59,296 KB
testcase_08 AC 232 ms
59,600 KB
testcase_09 AC 198 ms
58,252 KB
testcase_10 AC 251 ms
60,108 KB
testcase_11 AC 215 ms
59,464 KB
testcase_12 AC 237 ms
59,384 KB
testcase_13 AC 246 ms
60,492 KB
testcase_14 AC 138 ms
56,380 KB
testcase_15 AC 146 ms
56,056 KB
testcase_16 AC 244 ms
59,856 KB
testcase_17 AC 256 ms
60,716 KB
testcase_18 AC 250 ms
60,600 KB
testcase_19 AC 256 ms
60,620 KB
testcase_20 AC 123 ms
55,532 KB
testcase_21 AC 123 ms
55,724 KB
testcase_22 AC 124 ms
55,720 KB
testcase_23 AC 124 ms
56,084 KB
testcase_24 AC 152 ms
56,240 KB
testcase_25 AC 180 ms
56,056 KB
testcase_26 AC 128 ms
55,484 KB
testcase_27 AC 126 ms
55,940 KB
testcase_28 AC 127 ms
55,744 KB
testcase_29 AC 218 ms
59,412 KB
testcase_30 AC 195 ms
58,436 KB
testcase_31 AC 125 ms
55,776 KB
testcase_32 AC 126 ms
55,880 KB
testcase_33 AC 129 ms
55,940 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