結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-02-19 16:19:56 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 779 bytes |
コンパイル時間 | 4,392 ms |
コンパイル使用メモリ | 76,524 KB |
実行使用メモリ | 61,152 KB |
最終ジャッジ日時 | 2024-12-30 05:10:05 |
合計ジャッジ時間 | 13,270 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 20 |
ソースコード
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Box { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int l = scanner.nextInt(); int n = scanner.nextInt(); ArrayList<Integer> width = new ArrayList(); for(int i=0;i<n;i++){ width.add(scanner.nextInt()); } Collections.sort(width); int sum = 0; int count = 0; for(int i=0;i<width.size();i++){ sum += width.get(i); count++; if(sum >= l) break; } System.out.println(count); } }