結果

問題 No.5 数字のブロック
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-07 16:17:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 623 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 48,044 KB
最終ジャッジ日時 2024-04-29 00:47:21
合計ジャッジ時間 9,653 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
39,960 KB
testcase_01 AC 129 ms
41,060 KB
testcase_02 AC 116 ms
40,096 KB
testcase_03 AC 243 ms
46,476 KB
testcase_04 AC 218 ms
45,500 KB
testcase_05 AC 252 ms
47,248 KB
testcase_06 AC 237 ms
46,220 KB
testcase_07 AC 232 ms
46,272 KB
testcase_08 AC 243 ms
46,812 KB
testcase_09 AC 206 ms
43,472 KB
testcase_10 AC 255 ms
47,528 KB
testcase_11 AC 225 ms
46,016 KB
testcase_12 AC 252 ms
46,608 KB
testcase_13 AC 256 ms
47,128 KB
testcase_14 AC 144 ms
41,760 KB
testcase_15 AC 152 ms
41,300 KB
testcase_16 AC 252 ms
46,468 KB
testcase_17 AC 252 ms
48,044 KB
testcase_18 AC 264 ms
46,488 KB
testcase_19 AC 272 ms
47,496 KB
testcase_20 AC 128 ms
41,292 KB
testcase_21 AC 132 ms
41,288 KB
testcase_22 AC 116 ms
39,972 KB
testcase_23 AC 116 ms
40,096 KB
testcase_24 AC 143 ms
41,036 KB
testcase_25 AC 166 ms
41,900 KB
testcase_26 AC 128 ms
41,036 KB
testcase_27 AC 117 ms
40,236 KB
testcase_28 AC 128 ms
41,124 KB
testcase_29 AC 227 ms
45,492 KB
testcase_30 AC 201 ms
43,980 KB
testcase_31 AC 131 ms
41,332 KB
testcase_32 AC 115 ms
40,236 KB
testcase_33 AC 126 ms
41,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int l = koko.nextInt();
        int n = koko.nextInt();
        int[] w = new int[n];
        for(int i=0; i<n; i++){
            w[i] = koko.nextInt();
        }
        Arrays.sort(w);
        int wir = l;
        int count = 0;
        for(int i=0; i<n;i++){
            if(wir>=w[i]){
                wir = wir - w[i];
                count++;
            }else{
                break;
            }
        }
        System.out.println(count);
        
    }
}
0