結果

問題 No.5 数字のブロック
ユーザー 🐧しゅんチャマ🌸🐧しゅんチャマ🌸
提出日時 2023-09-06 22:29:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 259 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 3,196 ms
コンパイル使用メモリ 71,392 KB
実行使用メモリ 62,156 KB
最終ジャッジ日時 2023-09-06 22:29:40
合計ジャッジ時間 10,298 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,084 KB
testcase_01 AC 120 ms
56,060 KB
testcase_02 AC 119 ms
56,072 KB
testcase_03 AC 227 ms
59,392 KB
testcase_04 AC 201 ms
59,372 KB
testcase_05 AC 236 ms
59,596 KB
testcase_06 AC 217 ms
59,388 KB
testcase_07 AC 210 ms
59,172 KB
testcase_08 AC 238 ms
59,644 KB
testcase_09 AC 191 ms
58,392 KB
testcase_10 AC 237 ms
59,688 KB
testcase_11 AC 215 ms
59,864 KB
testcase_12 AC 234 ms
62,156 KB
testcase_13 AC 253 ms
60,240 KB
testcase_14 AC 132 ms
56,008 KB
testcase_15 AC 141 ms
55,636 KB
testcase_16 AC 242 ms
59,776 KB
testcase_17 AC 245 ms
60,136 KB
testcase_18 AC 251 ms
60,336 KB
testcase_19 AC 259 ms
60,596 KB
testcase_20 AC 120 ms
56,268 KB
testcase_21 AC 122 ms
56,096 KB
testcase_22 AC 122 ms
55,888 KB
testcase_23 AC 129 ms
55,412 KB
testcase_24 AC 158 ms
55,956 KB
testcase_25 AC 187 ms
56,136 KB
testcase_26 AC 122 ms
55,952 KB
testcase_27 AC 121 ms
55,712 KB
testcase_28 AC 123 ms
55,740 KB
testcase_29 AC 210 ms
59,260 KB
testcase_30 AC 202 ms
58,688 KB
testcase_31 AC 121 ms
55,696 KB
testcase_32 AC 121 ms
55,876 KB
testcase_33 AC 120 ms
56,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

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 count=0;
        int sum=0;
        for(int i=0;i<N;i++){
            sum+=W[i];
            if(sum>L){
                break;
            }
            count++;
        }
        System.out.println(count);
    }
}
0