結果

問題 No.5 数字のブロック
ユーザー prestopresto
提出日時 2015-10-08 23:00:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 282 ms / 5,000 ms
コード長 600 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 47,512 KB
最終ジャッジ日時 2024-04-29 06:29:28
合計ジャッジ時間 9,988 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
41,096 KB
testcase_01 AC 134 ms
41,228 KB
testcase_02 AC 134 ms
40,984 KB
testcase_03 AC 258 ms
46,400 KB
testcase_04 AC 234 ms
45,552 KB
testcase_05 AC 263 ms
46,348 KB
testcase_06 AC 244 ms
46,020 KB
testcase_07 AC 236 ms
45,788 KB
testcase_08 AC 250 ms
46,168 KB
testcase_09 AC 208 ms
43,372 KB
testcase_10 AC 273 ms
47,396 KB
testcase_11 AC 232 ms
45,852 KB
testcase_12 AC 254 ms
46,500 KB
testcase_13 AC 266 ms
46,520 KB
testcase_14 AC 149 ms
41,452 KB
testcase_15 AC 170 ms
41,796 KB
testcase_16 AC 266 ms
46,724 KB
testcase_17 AC 274 ms
47,512 KB
testcase_18 AC 272 ms
46,792 KB
testcase_19 AC 282 ms
47,456 KB
testcase_20 AC 134 ms
40,916 KB
testcase_21 AC 133 ms
41,180 KB
testcase_22 AC 119 ms
39,808 KB
testcase_23 AC 132 ms
41,000 KB
testcase_24 AC 170 ms
41,720 KB
testcase_25 AC 185 ms
42,068 KB
testcase_26 AC 135 ms
41,104 KB
testcase_27 AC 137 ms
41,248 KB
testcase_28 AC 132 ms
41,324 KB
testcase_29 AC 226 ms
45,440 KB
testcase_30 AC 213 ms
43,780 KB
testcase_31 AC 130 ms
41,152 KB
testcase_32 AC 131 ms
40,872 KB
testcase_33 AC 128 ms
40,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 sum = 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++){
           sum += w[i];
           count++;
           if(sum > l){
             System.out.println(i);
             return;
           }
        }
        System.out.println(count);
    }
}
0