結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2015-04-22 13:00:14 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 498 ms / 5,000 ms |
| コード長 | 973 bytes |
| コンパイル時間 | 2,772 ms |
| コンパイル使用メモリ | 91,484 KB |
| 実行使用メモリ | 58,632 KB |
| 最終ジャッジ日時 | 2024-11-17 22:39:18 |
| 合計ジャッジ時間 | 12,195 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
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();
}
}