結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2017-09-19 19:38:37 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 290 ms / 5,000 ms |
コード長 | 550 bytes |
コンパイル時間 | 3,720 ms |
コンパイル使用メモリ | 84,020 KB |
実行使用メモリ | 59,028 KB |
最終ジャッジ日時 | 2024-11-18 11:43:06 |
合計ジャッジ時間 | 11,351 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
package yukicoder; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class N5 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int n = sc.nextInt(); int c = 0; ArrayList<Integer> blocks = new ArrayList<Integer>(); for(int i = 0;i < n;++i){ blocks.add(sc.nextInt()); } Collections.sort(blocks); for(int b:blocks){ l -= b; if(l < 0){ System.out.println(c); return; } ++c; } System.out.println(c); } }