結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-28 22:01:06 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 82 ms / 5,000 ms |
| + 853µs | |
| コード長 | 663 bytes |
| 記録 | |
| コンパイル時間 | 1,648 ms |
| コンパイル使用メモリ | 91,720 KB |
| 実行使用メモリ | 44,452 KB |
| 最終ジャッジ日時 | 2026-09-09 22:06:13 |
| 合計ジャッジ時間 | 5,724 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// L
int numL = Integer.parseInt(br.readLine());
// N
int numN = Integer.parseInt(br.readLine());
// W1,W2,,,,,Wn
int[] numW = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).sorted().toArray();
int sum = 0;
int count = 0;
for (int num : numW) {
sum += num;
if (sum > numL) break; else count++;
}
System.out.println(count);
}
}