結果

問題 No.5 数字のブロック
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-11 22:29:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 682 bytes
コンパイル時間 4,881 ms
コンパイル使用メモリ 72,592 KB
実行使用メモリ 60,756 KB
最終ジャッジ日時 2023-09-10 13:03:35
合計ジャッジ時間 12,716 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,132 KB
testcase_01 AC 122 ms
55,892 KB
testcase_02 WA -
testcase_03 AC 230 ms
59,580 KB
testcase_04 AC 212 ms
59,416 KB
testcase_05 AC 240 ms
60,516 KB
testcase_06 AC 220 ms
59,952 KB
testcase_07 AC 213 ms
59,376 KB
testcase_08 AC 232 ms
59,436 KB
testcase_09 AC 192 ms
59,260 KB
testcase_10 AC 245 ms
60,272 KB
testcase_11 AC 214 ms
59,604 KB
testcase_12 AC 231 ms
59,992 KB
testcase_13 AC 237 ms
59,928 KB
testcase_14 AC 133 ms
55,940 KB
testcase_15 AC 146 ms
56,032 KB
testcase_16 AC 240 ms
60,100 KB
testcase_17 AC 251 ms
60,532 KB
testcase_18 AC 249 ms
60,756 KB
testcase_19 AC 259 ms
60,268 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 133 ms
55,632 KB
testcase_24 AC 163 ms
55,956 KB
testcase_25 AC 195 ms
55,892 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 210 ms
59,184 KB
testcase_30 AC 200 ms
58,564 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
                break;
            }else{
                blocks_width += W[i];
            }
        }
    }
}
0