結果

問題 No.5 数字のブロック
ユーザー skkbevskkbev
提出日時 2018-12-03 21:47:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 2,312 ms
コンパイル使用メモリ 73,220 KB
実行使用メモリ 63,056 KB
最終ジャッジ日時 2023-09-18 02:12:15
合計ジャッジ時間 11,077 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,876 KB
testcase_01 AC 127 ms
55,832 KB
testcase_02 WA -
testcase_03 AC 248 ms
59,576 KB
testcase_04 AC 235 ms
59,112 KB
testcase_05 WA -
testcase_06 AC 250 ms
59,764 KB
testcase_07 AC 223 ms
59,564 KB
testcase_08 AC 238 ms
59,248 KB
testcase_09 AC 203 ms
58,076 KB
testcase_10 AC 277 ms
60,280 KB
testcase_11 AC 231 ms
58,992 KB
testcase_12 AC 244 ms
59,592 KB
testcase_13 AC 257 ms
57,868 KB
testcase_14 AC 140 ms
55,836 KB
testcase_15 WA -
testcase_16 AC 261 ms
60,380 KB
testcase_17 AC 275 ms
60,140 KB
testcase_18 AC 273 ms
60,020 KB
testcase_19 AC 279 ms
61,100 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 128 ms
55,844 KB
testcase_24 AC 156 ms
55,716 KB
testcase_25 AC 190 ms
56,516 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int l = sc.nextInt();
        int n = sc.nextInt();
        
        List<Integer> list = new ArrayList<>();
        
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }

        Collections.sort(list);
        
        int i3 = 0;
        for (int w = 0; w < n; w++) {
            i3 += list.get(w);
                if (i3 >= l) {
                    System.out.println(w);
                    break;
                }
        }
    }
}
0