結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-06-21 07:16:50 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 293 ms / 5,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 2,405 ms |
コンパイル使用メモリ | 75,384 KB |
実行使用メモリ | 59,484 KB |
最終ジャッジ日時 | 2024-11-18 08:43:15 |
合計ジャッジ時間 | 9,912 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int L = sc.nextInt(); int N = sc.nextInt(); ArrayList<Integer> wide = new ArrayList<Integer>(); for( int i = 0 ; i < N ; i++ ){ wide.add(sc.nextInt()); } Collections.sort(wide); int w_sum = 0; int count = 0; for( int i = 0 ; i < N ; i++ ){ w_sum += wide.get(i); if( w_sum > L)break; count++; } System.out.println(count); } }