結果

問題 No.5 数字のブロック
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 20:55:37
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 531 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 76,020 KB
実行使用メモリ 54,688 KB
最終ジャッジ日時 2024-05-04 00:23:49
合計ジャッジ時間 10,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,268 KB
testcase_01 AC 138 ms
41,248 KB
testcase_02 RE -
testcase_03 AC 255 ms
46,596 KB
testcase_04 AC 231 ms
45,832 KB
testcase_05 AC 268 ms
46,952 KB
testcase_06 AC 242 ms
46,252 KB
testcase_07 AC 237 ms
45,628 KB
testcase_08 AC 256 ms
46,576 KB
testcase_09 AC 215 ms
43,260 KB
testcase_10 AC 265 ms
46,988 KB
testcase_11 AC 229 ms
46,392 KB
testcase_12 AC 255 ms
46,500 KB
testcase_13 AC 264 ms
46,936 KB
testcase_14 AC 150 ms
41,700 KB
testcase_15 AC 165 ms
41,368 KB
testcase_16 AC 266 ms
46,668 KB
testcase_17 AC 276 ms
47,308 KB
testcase_18 AC 277 ms
46,948 KB
testcase_19 AC 276 ms
47,212 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 137 ms
41,096 KB
testcase_24 AC 162 ms
41,760 KB
testcase_25 AC 191 ms
42,084 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 231 ms
45,780 KB
testcase_30 AC 214 ms
43,820 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++;
if(c==N){break;}
        }
        System.out.println(c);
    }
}
0