結果

問題 No.5 数字のブロック
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 21:05:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 266 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 47,756 KB
最終ジャッジ日時 2024-04-29 08:37:45
合計ジャッジ時間 8,933 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,376 KB
testcase_01 AC 130 ms
41,252 KB
testcase_02 AC 130 ms
41,144 KB
testcase_03 AC 235 ms
46,372 KB
testcase_04 AC 212 ms
45,516 KB
testcase_05 AC 237 ms
47,112 KB
testcase_06 AC 212 ms
45,820 KB
testcase_07 AC 205 ms
45,672 KB
testcase_08 AC 228 ms
46,524 KB
testcase_09 AC 195 ms
43,664 KB
testcase_10 AC 223 ms
47,236 KB
testcase_11 AC 194 ms
45,852 KB
testcase_12 AC 217 ms
46,556 KB
testcase_13 AC 227 ms
46,648 KB
testcase_14 AC 124 ms
41,196 KB
testcase_15 AC 144 ms
41,952 KB
testcase_16 AC 247 ms
46,128 KB
testcase_17 AC 266 ms
47,468 KB
testcase_18 AC 263 ms
47,648 KB
testcase_19 AC 253 ms
47,756 KB
testcase_20 AC 120 ms
41,568 KB
testcase_21 AC 120 ms
41,452 KB
testcase_22 AC 98 ms
41,276 KB
testcase_23 AC 130 ms
41,160 KB
testcase_24 AC 153 ms
41,524 KB
testcase_25 AC 172 ms
42,072 KB
testcase_26 AC 123 ms
41,144 KB
testcase_27 AC 124 ms
41,612 KB
testcase_28 AC 105 ms
40,884 KB
testcase_29 AC 207 ms
45,776 KB
testcase_30 AC 201 ms
44,448 KB
testcase_31 AC 131 ms
41,576 KB
testcase_32 AC 112 ms
40,100 KB
testcase_33 AC 103 ms
41,360 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