結果

問題 No.5 数字のブロック
ユーザー villachvillach
提出日時 2017-09-19 19:38:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 299 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 4,127 ms
コンパイル使用メモリ 74,936 KB
実行使用メモリ 62,108 KB
最終ジャッジ日時 2023-08-11 17:47:43
合計ジャッジ時間 12,731 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,592 KB
testcase_01 AC 135 ms
55,592 KB
testcase_02 AC 133 ms
55,740 KB
testcase_03 AC 264 ms
60,144 KB
testcase_04 AC 242 ms
59,596 KB
testcase_05 AC 277 ms
60,748 KB
testcase_06 AC 253 ms
60,228 KB
testcase_07 AC 237 ms
59,148 KB
testcase_08 AC 256 ms
57,448 KB
testcase_09 AC 214 ms
57,996 KB
testcase_10 AC 284 ms
58,980 KB
testcase_11 AC 241 ms
59,880 KB
testcase_12 AC 258 ms
62,108 KB
testcase_13 AC 275 ms
58,216 KB
testcase_14 AC 151 ms
55,396 KB
testcase_15 AC 167 ms
55,840 KB
testcase_16 AC 275 ms
59,916 KB
testcase_17 AC 299 ms
61,024 KB
testcase_18 AC 291 ms
60,784 KB
testcase_19 AC 299 ms
60,688 KB
testcase_20 AC 131 ms
55,744 KB
testcase_21 AC 133 ms
55,448 KB
testcase_22 AC 139 ms
55,780 KB
testcase_23 AC 136 ms
55,340 KB
testcase_24 AC 170 ms
56,032 KB
testcase_25 AC 202 ms
55,700 KB
testcase_26 AC 134 ms
53,716 KB
testcase_27 AC 141 ms
55,696 KB
testcase_28 AC 134 ms
55,752 KB
testcase_29 AC 239 ms
59,132 KB
testcase_30 AC 221 ms
58,572 KB
testcase_31 AC 137 ms
55,332 KB
testcase_32 AC 136 ms
55,384 KB
testcase_33 AC 131 ms
55,540 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