結果

問題 No.5 数字のブロック
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 21:05:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 262 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 2,436 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 60,532 KB
最終ジャッジ日時 2023-08-11 16:49:48
合計ジャッジ時間 10,064 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,672 KB
testcase_01 AC 130 ms
55,464 KB
testcase_02 AC 128 ms
55,464 KB
testcase_03 AC 241 ms
59,684 KB
testcase_04 AC 202 ms
59,296 KB
testcase_05 AC 244 ms
60,532 KB
testcase_06 AC 227 ms
59,692 KB
testcase_07 AC 215 ms
43,680 KB
testcase_08 AC 231 ms
45,076 KB
testcase_09 AC 201 ms
42,148 KB
testcase_10 AC 244 ms
45,052 KB
testcase_11 AC 221 ms
44,016 KB
testcase_12 AC 242 ms
45,760 KB
testcase_13 AC 243 ms
44,896 KB
testcase_14 AC 133 ms
39,716 KB
testcase_15 AC 142 ms
39,764 KB
testcase_16 AC 247 ms
44,968 KB
testcase_17 AC 260 ms
46,060 KB
testcase_18 AC 254 ms
46,072 KB
testcase_19 AC 262 ms
44,952 KB
testcase_20 AC 122 ms
39,280 KB
testcase_21 AC 123 ms
39,752 KB
testcase_22 AC 122 ms
39,672 KB
testcase_23 AC 122 ms
39,792 KB
testcase_24 AC 166 ms
39,624 KB
testcase_25 AC 189 ms
56,232 KB
testcase_26 AC 126 ms
55,812 KB
testcase_27 AC 124 ms
56,164 KB
testcase_28 AC 124 ms
55,664 KB
testcase_29 AC 214 ms
58,984 KB
testcase_30 AC 200 ms
58,788 KB
testcase_31 AC 126 ms
55,644 KB
testcase_32 AC 126 ms
55,700 KB
testcase_33 AC 125 ms
55,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int N = sc.nextInt();
        int [] W = new int [N];
        for(int i=0; i<N; i++){
            W[i]=sc.nextInt();
        }
        Arrays.sort(W);
        int i =0;
        int s =0;
        int c =0;
        while(true){
                s=s+W[i];
                if(s>L){break;}
                i++;
                c++;
               if(c==N){break;}
        }
        System.out.println(c);
    }
}
0