結果

問題 No.5 数字のブロック
ユーザー bigbear90560bigbear90560
提出日時 2015-07-03 22:09:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 789 bytes
コンパイル時間 3,954 ms
コンパイル使用メモリ 75,192 KB
実行使用メモリ 47,788 KB
最終ジャッジ日時 2024-04-29 01:03:22
合計ジャッジ時間 11,634 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,584 KB
testcase_01 AC 137 ms
41,612 KB
testcase_02 AC 136 ms
41,452 KB
testcase_03 AC 251 ms
46,392 KB
testcase_04 AC 223 ms
45,640 KB
testcase_05 AC 261 ms
47,556 KB
testcase_06 AC 237 ms
46,840 KB
testcase_07 AC 237 ms
46,000 KB
testcase_08 AC 244 ms
46,892 KB
testcase_09 AC 205 ms
43,300 KB
testcase_10 AC 259 ms
47,448 KB
testcase_11 AC 225 ms
46,320 KB
testcase_12 AC 252 ms
47,048 KB
testcase_13 AC 256 ms
46,856 KB
testcase_14 AC 146 ms
41,372 KB
testcase_15 AC 156 ms
41,504 KB
testcase_16 AC 255 ms
46,628 KB
testcase_17 AC 277 ms
47,484 KB
testcase_18 AC 272 ms
47,768 KB
testcase_19 AC 279 ms
47,788 KB
testcase_20 AC 132 ms
41,352 KB
testcase_21 AC 132 ms
41,300 KB
testcase_22 AC 132 ms
41,300 KB
testcase_23 AC 136 ms
41,660 KB
testcase_24 AC 157 ms
41,684 KB
testcase_25 AC 179 ms
41,964 KB
testcase_26 AC 135 ms
41,300 KB
testcase_27 AC 134 ms
41,444 KB
testcase_28 AC 131 ms
41,204 KB
testcase_29 AC 231 ms
45,660 KB
testcase_30 AC 208 ms
44,264 KB
testcase_31 AC 128 ms
41,528 KB
testcase_32 AC 130 ms
41,300 KB
testcase_33 AC 135 ms
41,416 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