結果

問題 No.5 数字のブロック
ユーザー villachvillach
提出日時 2017-09-19 19:38:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 297 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 4,026 ms
コンパイル使用メモリ 76,104 KB
実行使用メモリ 47,756 KB
最終ジャッジ日時 2024-04-29 09:22:35
合計ジャッジ時間 11,860 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
41,076 KB
testcase_01 AC 132 ms
41,244 KB
testcase_02 AC 125 ms
41,160 KB
testcase_03 AC 260 ms
46,152 KB
testcase_04 AC 235 ms
45,648 KB
testcase_05 AC 257 ms
47,152 KB
testcase_06 AC 246 ms
45,832 KB
testcase_07 AC 230 ms
45,800 KB
testcase_08 AC 251 ms
46,852 KB
testcase_09 AC 203 ms
43,368 KB
testcase_10 AC 277 ms
47,684 KB
testcase_11 AC 243 ms
45,948 KB
testcase_12 AC 265 ms
46,192 KB
testcase_13 AC 283 ms
46,652 KB
testcase_14 AC 152 ms
41,280 KB
testcase_15 AC 171 ms
41,532 KB
testcase_16 AC 283 ms
47,256 KB
testcase_17 AC 289 ms
47,568 KB
testcase_18 AC 292 ms
47,756 KB
testcase_19 AC 297 ms
47,680 KB
testcase_20 AC 128 ms
41,020 KB
testcase_21 AC 132 ms
41,412 KB
testcase_22 AC 116 ms
39,992 KB
testcase_23 AC 116 ms
40,240 KB
testcase_24 AC 161 ms
41,468 KB
testcase_25 AC 185 ms
41,920 KB
testcase_26 AC 133 ms
41,112 KB
testcase_27 AC 133 ms
41,036 KB
testcase_28 AC 117 ms
40,200 KB
testcase_29 AC 239 ms
46,224 KB
testcase_30 AC 208 ms
44,068 KB
testcase_31 AC 131 ms
41,116 KB
testcase_32 AC 129 ms
41,052 KB
testcase_33 AC 133 ms
41,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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