結果

問題 No.5 数字のブロック
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-22 13:00:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 553 ms / 5,000 ms
コード長 973 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 47,868 KB
最終ジャッジ日時 2024-04-29 00:51:10
合計ジャッジ時間 12,976 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
41,508 KB
testcase_01 AC 139 ms
41,608 KB
testcase_02 AC 125 ms
40,240 KB
testcase_03 AC 403 ms
47,144 KB
testcase_04 AC 291 ms
45,784 KB
testcase_05 AC 459 ms
47,272 KB
testcase_06 AC 316 ms
47,100 KB
testcase_07 AC 309 ms
46,852 KB
testcase_08 AC 402 ms
47,020 KB
testcase_09 AC 234 ms
46,028 KB
testcase_10 AC 482 ms
47,248 KB
testcase_11 AC 296 ms
47,396 KB
testcase_12 AC 407 ms
47,868 KB
testcase_13 AC 463 ms
47,072 KB
testcase_14 AC 150 ms
41,468 KB
testcase_15 AC 159 ms
42,248 KB
testcase_16 AC 476 ms
47,016 KB
testcase_17 AC 534 ms
47,156 KB
testcase_18 AC 516 ms
47,652 KB
testcase_19 AC 553 ms
47,264 KB
testcase_20 AC 138 ms
41,660 KB
testcase_21 AC 124 ms
40,376 KB
testcase_22 AC 124 ms
40,356 KB
testcase_23 AC 143 ms
41,708 KB
testcase_24 AC 176 ms
42,428 KB
testcase_25 AC 190 ms
44,240 KB
testcase_26 AC 141 ms
41,564 KB
testcase_27 AC 129 ms
40,204 KB
testcase_28 AC 142 ms
41,672 KB
testcase_29 AC 293 ms
45,688 KB
testcase_30 AC 235 ms
46,268 KB
testcase_31 AC 142 ms
41,528 KB
testcase_32 AC 141 ms
41,532 KB
testcase_33 AC 125 ms
40,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.*;

import static java.lang.Math.*;

public class Main {
    private void solve() {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        sc.nextLine();
        List<Integer> sorted = Stream.of(sc.nextLine().split(" "))
                                     .map(Integer::valueOf)
                                     .sorted()
                                     .collect(Collectors.toList());
        int[] sums = IntStream.range(0, sorted.size())
                              .map(i -> sorted.subList(0, i+1)
                                              .stream()
                                              .reduce(0, (x, y) -> x + y))
                              .toArray();
        System.out.println(abs(Arrays.binarySearch(sums, l) + 1));
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}
0