結果

問題 No.5 数字のブロック
ユーザー sasukesasuke
提出日時 2016-06-21 07:16:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 294 ms / 5,000 ms
コード長 478 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 75,536 KB
実行使用メモリ 47,904 KB
最終ジャッジ日時 2024-04-29 07:22:48
合計ジャッジ時間 10,117 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
40,960 KB
testcase_01 AC 129 ms
40,872 KB
testcase_02 AC 129 ms
41,252 KB
testcase_03 AC 255 ms
46,468 KB
testcase_04 AC 233 ms
46,056 KB
testcase_05 AC 278 ms
47,164 KB
testcase_06 AC 244 ms
46,256 KB
testcase_07 AC 234 ms
45,644 KB
testcase_08 AC 253 ms
45,908 KB
testcase_09 AC 209 ms
43,468 KB
testcase_10 AC 285 ms
47,388 KB
testcase_11 AC 236 ms
45,880 KB
testcase_12 AC 259 ms
46,524 KB
testcase_13 AC 266 ms
46,596 KB
testcase_14 AC 142 ms
41,528 KB
testcase_15 AC 156 ms
41,452 KB
testcase_16 AC 280 ms
47,332 KB
testcase_17 AC 293 ms
47,768 KB
testcase_18 AC 288 ms
47,600 KB
testcase_19 AC 294 ms
47,904 KB
testcase_20 AC 131 ms
41,004 KB
testcase_21 AC 130 ms
40,976 KB
testcase_22 AC 132 ms
41,368 KB
testcase_23 AC 121 ms
39,960 KB
testcase_24 AC 158 ms
41,436 KB
testcase_25 AC 181 ms
41,700 KB
testcase_26 AC 117 ms
40,328 KB
testcase_27 AC 130 ms
41,180 KB
testcase_28 AC 129 ms
40,828 KB
testcase_29 AC 238 ms
45,920 KB
testcase_30 AC 215 ms
43,808 KB
testcase_31 AC 130 ms
41,208 KB
testcase_32 AC 130 ms
41,564 KB
testcase_33 AC 117 ms
40,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
}
0