結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2020-12-28 22:01:06 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 2,747 ms |
コンパイル使用メモリ | 79,664 KB |
実行使用メモリ | 40,900 KB |
最終ジャッジ日時 | 2024-10-04 00:20:49 |
合計ジャッジ時間 | 6,445 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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); } }