結果

問題 No.5 数字のブロック
ユーザー b4belb4bel
提出日時 2015-05-24 17:41:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 3,357 ms
コンパイル使用メモリ 74,888 KB
実行使用メモリ 47,724 KB
最終ジャッジ日時 2024-04-29 00:56:36
合計ジャッジ時間 10,818 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,172 KB
testcase_01 AC 130 ms
41,252 KB
testcase_02 AC 116 ms
40,224 KB
testcase_03 AC 237 ms
46,876 KB
testcase_04 AC 222 ms
45,212 KB
testcase_05 AC 254 ms
46,732 KB
testcase_06 AC 233 ms
46,836 KB
testcase_07 AC 229 ms
45,984 KB
testcase_08 AC 235 ms
46,396 KB
testcase_09 AC 205 ms
43,428 KB
testcase_10 AC 254 ms
47,156 KB
testcase_11 AC 220 ms
46,284 KB
testcase_12 AC 246 ms
46,732 KB
testcase_13 AC 258 ms
47,324 KB
testcase_14 AC 146 ms
41,512 KB
testcase_15 AC 151 ms
41,816 KB
testcase_16 AC 247 ms
46,232 KB
testcase_17 AC 266 ms
47,724 KB
testcase_18 AC 272 ms
47,532 KB
testcase_19 AC 272 ms
47,228 KB
testcase_20 AC 132 ms
41,488 KB
testcase_21 AC 114 ms
40,268 KB
testcase_22 AC 128 ms
41,388 KB
testcase_23 AC 132 ms
41,272 KB
testcase_24 AC 164 ms
41,588 KB
testcase_25 AC 185 ms
42,120 KB
testcase_26 AC 129 ms
41,364 KB
testcase_27 AC 125 ms
41,412 KB
testcase_28 AC 131 ms
41,140 KB
testcase_29 AC 221 ms
45,932 KB
testcase_30 AC 204 ms
43,704 KB
testcase_31 AC 118 ms
39,876 KB
testcase_32 AC 121 ms
40,392 KB
testcase_33 AC 117 ms
39,972 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