結果

問題 No.5 数字のブロック
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-22 13:00:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 555 ms / 5,000 ms
コード長 973 bytes
コンパイル時間 2,796 ms
コンパイル使用メモリ 80,616 KB
実行使用メモリ 61,056 KB
最終ジャッジ日時 2023-08-11 08:16:37
合計ジャッジ時間 13,461 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,168 KB
testcase_01 AC 132 ms
56,108 KB
testcase_02 AC 129 ms
56,236 KB
testcase_03 AC 435 ms
60,300 KB
testcase_04 AC 287 ms
58,644 KB
testcase_05 AC 469 ms
60,916 KB
testcase_06 AC 357 ms
59,764 KB
testcase_07 AC 307 ms
59,904 KB
testcase_08 AC 420 ms
60,200 KB
testcase_09 AC 220 ms
58,992 KB
testcase_10 AC 497 ms
59,932 KB
testcase_11 AC 304 ms
60,176 KB
testcase_12 AC 444 ms
59,800 KB
testcase_13 AC 474 ms
60,788 KB
testcase_14 AC 141 ms
55,832 KB
testcase_15 AC 154 ms
56,176 KB
testcase_16 AC 475 ms
60,332 KB
testcase_17 AC 537 ms
61,056 KB
testcase_18 AC 524 ms
61,028 KB
testcase_19 AC 555 ms
60,764 KB
testcase_20 AC 132 ms
55,596 KB
testcase_21 AC 132 ms
55,812 KB
testcase_22 AC 133 ms
55,984 KB
testcase_23 AC 131 ms
55,964 KB
testcase_24 AC 167 ms
55,700 KB
testcase_25 AC 180 ms
58,436 KB
testcase_26 AC 133 ms
55,916 KB
testcase_27 AC 133 ms
55,956 KB
testcase_28 AC 132 ms
55,900 KB
testcase_29 AC 300 ms
58,556 KB
testcase_30 AC 225 ms
58,552 KB
testcase_31 AC 130 ms
56,032 KB
testcase_32 AC 132 ms
56,296 KB
testcase_33 AC 131 ms
55,848 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