結果

問題 No.5 数字のブロック
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-07 16:17:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 255 ms / 5,000 ms
コード長 623 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 71,964 KB
実行使用メモリ 61,772 KB
最終ジャッジ日時 2023-08-11 08:12:38
合計ジャッジ時間 10,086 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,768 KB
testcase_01 AC 119 ms
55,800 KB
testcase_02 AC 121 ms
55,712 KB
testcase_03 AC 227 ms
59,492 KB
testcase_04 AC 210 ms
59,092 KB
testcase_05 AC 245 ms
60,716 KB
testcase_06 AC 214 ms
59,772 KB
testcase_07 AC 210 ms
58,848 KB
testcase_08 AC 215 ms
59,816 KB
testcase_09 AC 194 ms
58,072 KB
testcase_10 AC 238 ms
59,740 KB
testcase_11 AC 213 ms
59,292 KB
testcase_12 AC 235 ms
61,772 KB
testcase_13 AC 240 ms
59,664 KB
testcase_14 AC 138 ms
56,288 KB
testcase_15 AC 156 ms
55,952 KB
testcase_16 AC 242 ms
59,896 KB
testcase_17 AC 249 ms
60,252 KB
testcase_18 AC 253 ms
60,296 KB
testcase_19 AC 255 ms
60,492 KB
testcase_20 AC 122 ms
55,840 KB
testcase_21 AC 124 ms
55,724 KB
testcase_22 AC 124 ms
56,164 KB
testcase_23 AC 119 ms
54,100 KB
testcase_24 AC 152 ms
56,436 KB
testcase_25 AC 173 ms
56,092 KB
testcase_26 AC 125 ms
56,020 KB
testcase_27 AC 122 ms
58,060 KB
testcase_28 AC 122 ms
55,604 KB
testcase_29 AC 209 ms
59,044 KB
testcase_30 AC 196 ms
58,208 KB
testcase_31 AC 120 ms
55,592 KB
testcase_32 AC 123 ms
56,020 KB
testcase_33 AC 122 ms
55,412 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