結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-08-03 13:05:35 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 588 bytes |
コンパイル時間 | 2,413 ms |
コンパイル使用メモリ | 76,240 KB |
実行使用メモリ | 47,852 KB |
最終ジャッジ日時 | 2024-11-06 23:42:27 |
合計ジャッジ時間 | 10,643 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 WA * 7 |
ソースコード
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int n = sc.nextInt(); List<Integer> w = new ArrayList<Integer>(); for(int i=0; i<n; i++){ w.add(sc.nextInt()); } sc.close(); Collections.sort(w); int sum = 0; int count; for(count = 0; count<w.size(); count++){ if(l > sum + w.get(count)){ sum = sum + w.get(count); }else{ break; } } System.out.println(count); } }