結果

問題 No.5 数字のブロック
ユーザー bigbear90560bigbear90560
提出日時 2015-07-03 22:09:53
言語 Java19
(openjdk 21)
結果
AC  
実行時間 256 ms / 5,000 ms
コード長 789 bytes
コンパイル時間 3,101 ms
コンパイル使用メモリ 71,536 KB
実行使用メモリ 60,400 KB
最終ジャッジ日時 2023-08-11 08:30:06
合計ジャッジ時間 10,673 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,760 KB
testcase_01 AC 123 ms
55,712 KB
testcase_02 AC 122 ms
55,692 KB
testcase_03 AC 215 ms
59,200 KB
testcase_04 AC 212 ms
59,080 KB
testcase_05 AC 240 ms
60,116 KB
testcase_06 AC 219 ms
58,992 KB
testcase_07 AC 213 ms
59,148 KB
testcase_08 AC 228 ms
59,624 KB
testcase_09 AC 197 ms
60,400 KB
testcase_10 AC 249 ms
59,860 KB
testcase_11 AC 217 ms
59,756 KB
testcase_12 AC 235 ms
59,912 KB
testcase_13 AC 239 ms
59,540 KB
testcase_14 AC 137 ms
55,856 KB
testcase_15 AC 156 ms
55,644 KB
testcase_16 AC 244 ms
59,736 KB
testcase_17 AC 252 ms
59,876 KB
testcase_18 AC 250 ms
60,324 KB
testcase_19 AC 256 ms
60,196 KB
testcase_20 AC 125 ms
56,264 KB
testcase_21 AC 123 ms
55,684 KB
testcase_22 AC 124 ms
56,276 KB
testcase_23 AC 124 ms
55,712 KB
testcase_24 AC 151 ms
55,760 KB
testcase_25 AC 182 ms
56,836 KB
testcase_26 AC 126 ms
56,164 KB
testcase_27 AC 125 ms
55,748 KB
testcase_28 AC 125 ms
56,124 KB
testcase_29 AC 213 ms
59,064 KB
testcase_30 AC 202 ms
58,512 KB
testcase_31 AC 125 ms
55,724 KB
testcase_32 AC 123 ms
55,792 KB
testcase_33 AC 123 ms
56,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

/**
 * No.5 数字のブロック
 */
public class NumberBlock {

	public static void main(String[] args) {

		// 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();	// 幅
        int b = sc.nextInt();	// ブロック数
    	int[] c = new int[b];

        for (int i=0;i<b;i++) {
        	c[i] = sc.nextInt();	// ブロック幅
        }
        
        // 配列をソート
        Arrays.sort(c);
        
        int resWidth = 0;
        int resCount = 0;
        for (int n : c) {
        	resWidth += n;
			if (a >= resWidth) {
				resCount++;
			} else {
				break;
			}
        }
        System.out.println(resCount);
	}

}
0