結果

問題 No.5 数字のブロック
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-11 22:42:48
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 729 bytes
コンパイル時間 3,437 ms
コンパイル使用メモリ 76,776 KB
実行使用メモリ 62,144 KB
最終ジャッジ日時 2023-09-10 17:39:47
合計ジャッジ時間 11,540 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 125 ms
55,516 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 128 ms
56,084 KB
testcase_21 AC 127 ms
56,028 KB
testcase_22 AC 126 ms
56,100 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 125 ms
55,732 KB
testcase_27 AC 125 ms
55,500 KB
testcase_28 AC 127 ms
55,864 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 126 ms
55,860 KB
testcase_32 AC 127 ms
55,912 KB
testcase_33 AC 124 ms
56,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Arrays;

public class NumBlocks{
    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 blocks_width = 0;
        for(int i = 0; i < N; i++){
            if(blocks_width + W[i] > L){
                System.out.println(i);
                System.exit(1);
            }else{
                blocks_width += W[i];
            }
        }
        System.out.println(W.length);
    }
}
0