結果

問題 No.5 数字のブロック
ユーザー klkl
提出日時 2020-09-30 10:50:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 265 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 72,592 KB
実行使用メモリ 61,240 KB
最終ジャッジ日時 2023-09-19 05:32:50
合計ジャッジ時間 10,492 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
55,504 KB
testcase_01 AC 131 ms
55,824 KB
testcase_02 AC 130 ms
55,676 KB
testcase_03 AC 244 ms
59,736 KB
testcase_04 AC 223 ms
57,064 KB
testcase_05 AC 255 ms
60,476 KB
testcase_06 AC 219 ms
60,004 KB
testcase_07 AC 221 ms
59,228 KB
testcase_08 AC 236 ms
59,136 KB
testcase_09 AC 201 ms
58,352 KB
testcase_10 AC 258 ms
60,232 KB
testcase_11 AC 222 ms
59,540 KB
testcase_12 AC 241 ms
58,488 KB
testcase_13 AC 255 ms
60,696 KB
testcase_14 AC 143 ms
55,536 KB
testcase_15 AC 155 ms
55,968 KB
testcase_16 AC 251 ms
59,984 KB
testcase_17 AC 260 ms
60,844 KB
testcase_18 AC 265 ms
61,240 KB
testcase_19 AC 260 ms
60,712 KB
testcase_20 AC 126 ms
54,348 KB
testcase_21 AC 127 ms
55,664 KB
testcase_22 AC 126 ms
55,660 KB
testcase_23 AC 129 ms
55,808 KB
testcase_24 AC 153 ms
56,028 KB
testcase_25 AC 183 ms
56,128 KB
testcase_26 AC 129 ms
55,516 KB
testcase_27 AC 126 ms
55,888 KB
testcase_28 AC 128 ms
55,668 KB
testcase_29 AC 217 ms
59,256 KB
testcase_30 AC 202 ms
58,360 KB
testcase_31 AC 125 ms
55,848 KB
testcase_32 AC 126 ms
55,788 KB
testcase_33 AC 129 ms
55,924 KB
権限があれば一括ダウンロードができます

ソースコード

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];
        int result=0;
        int count=0;
        for(int i=0;i<n;i++){
            w[i]=sc.nextInt();
        }
        Arrays.sort(w);
        for(int i=0;i<n;i++){
            result+=w[i];
            if(result>l){
                break;
            }
            count++;
        }
        System.out.println(count);
    }
}
0