結果

問題 No.5 数字のブロック
ユーザー b4belb4bel
提出日時 2015-05-24 17:41:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 3,501 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 60,572 KB
最終ジャッジ日時 2023-08-11 08:23:01
合計ジャッジ時間 10,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
54,340 KB
testcase_01 AC 125 ms
56,100 KB
testcase_02 AC 122 ms
55,748 KB
testcase_03 AC 228 ms
60,120 KB
testcase_04 AC 212 ms
58,972 KB
testcase_05 AC 245 ms
59,848 KB
testcase_06 AC 222 ms
59,680 KB
testcase_07 AC 213 ms
59,008 KB
testcase_08 AC 229 ms
60,308 KB
testcase_09 AC 199 ms
58,436 KB
testcase_10 AC 238 ms
59,712 KB
testcase_11 AC 211 ms
59,088 KB
testcase_12 AC 231 ms
60,192 KB
testcase_13 AC 239 ms
59,452 KB
testcase_14 AC 136 ms
55,792 KB
testcase_15 AC 153 ms
56,268 KB
testcase_16 AC 240 ms
59,344 KB
testcase_17 AC 252 ms
60,520 KB
testcase_18 AC 248 ms
60,572 KB
testcase_19 AC 254 ms
60,492 KB
testcase_20 AC 120 ms
55,600 KB
testcase_21 AC 123 ms
55,492 KB
testcase_22 AC 121 ms
55,776 KB
testcase_23 AC 124 ms
56,128 KB
testcase_24 AC 149 ms
55,952 KB
testcase_25 AC 181 ms
56,384 KB
testcase_26 AC 124 ms
55,668 KB
testcase_27 AC 123 ms
55,632 KB
testcase_28 AC 124 ms
56,212 KB
testcase_29 AC 208 ms
59,016 KB
testcase_30 AC 196 ms
58,864 KB
testcase_31 AC 123 ms
56,036 KB
testcase_32 AC 122 ms
55,744 KB
testcase_33 AC 121 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package coder;

import java.util.Arrays;
import java.util.Scanner;

public class No5 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int width = scanner.nextInt();
		int num = scanner.nextInt();
		int[] blockWidth = new int[num];

		for(int i = 0; i < num; i++) {
			blockWidth[i] = scanner.nextInt();
		}

		Arrays.sort(blockWidth);

		int sum = 0;
		int maxNum = 0;
		for(int i = 0; i < num; i++) {
			sum += blockWidth[i];
			if(sum > width) {
				break;
			}
			maxNum++;
		}
		System.out.println(maxNum);

		scanner.close();
	}

}
0