結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2023-09-05 14:56:40 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 638 bytes |
コンパイル時間 | 3,320 ms |
コンパイル使用メモリ | 86,372 KB |
実行使用メモリ | 48,012 KB |
最終ジャッジ日時 | 2024-06-23 10:33:57 |
合計ジャッジ時間 | 11,183 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 RE * 7 |
ソースコード
import java.util.Scanner; import java.util.ArrayList; import java.util.List; import java.util.Collections; class Wandbox { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List<Integer> list = new ArrayList<>(); int l = sc.nextInt(); int n = sc.nextInt(); for (int i = 0; i < n; i++) { list.add(sc.nextInt()); } Collections.sort(list); int sum = 0; int cnt = 0; for (int i = 0; sum < l; i++) { sum += list.get(i); if (sum <= l) { cnt++; } } System.out.println(cnt); } }