結果

問題 No.5 数字のブロック
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 20:53:01
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 514 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 74,908 KB
実行使用メモリ 47,568 KB
最終ジャッジ日時 2024-05-04 00:23:12
合計ジャッジ時間 8,773 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
41,232 KB
testcase_01 AC 117 ms
41,072 KB
testcase_02 RE -
testcase_03 AC 224 ms
46,408 KB
testcase_04 AC 200 ms
45,540 KB
testcase_05 AC 228 ms
46,888 KB
testcase_06 AC 223 ms
46,280 KB
testcase_07 AC 195 ms
45,768 KB
testcase_08 AC 224 ms
45,908 KB
testcase_09 AC 178 ms
43,372 KB
testcase_10 AC 222 ms
47,496 KB
testcase_11 AC 194 ms
45,636 KB
testcase_12 AC 209 ms
46,720 KB
testcase_13 AC 226 ms
47,128 KB
testcase_14 AC 124 ms
41,804 KB
testcase_15 AC 144 ms
41,952 KB
testcase_16 AC 228 ms
46,592 KB
testcase_17 AC 238 ms
47,248 KB
testcase_18 AC 248 ms
47,568 KB
testcase_19 AC 241 ms
47,528 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 103 ms
41,452 KB
testcase_24 AC 148 ms
41,864 KB
testcase_25 AC 158 ms
42,296 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 186 ms
45,376 KB
testcase_30 AC 183 ms
43,844 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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 =W[i];
        int c =0;
        while(s<=L){
                i++;
                s=s+W[i];
                c++;
        }
        System.out.println(c);
    }
}
0