結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2021-11-15 23:11:56 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,107 bytes |
コンパイル時間 | 2,096 ms |
コンパイル使用メモリ | 79,352 KB |
実行使用メモリ | 52,624 KB |
最終ジャッジ日時 | 2024-12-15 07:55:37 |
合計ジャッジ時間 | 5,848 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 14 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.stream.Stream; class Main { public static void main(String[] args) { no5(); } // No.5 数字のブロック private static void no5() { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // 箱の幅 String l; // ブロックの数 String n; // 各ブロックの幅 String block; try { l = reader.readLine(); n = reader.readLine(); block = reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } int[] numbers = Stream.of(block.split(" ")).mapToInt(Integer::parseInt).sorted().toArray(); int width = Integer.parseInt(l); int max = 0; for (int i : numbers) { if (i < width) { width -= i; max++; } else { System.out.println(max); break; }; } } }