結果

問題 No.5 数字のブロック
ユーザー bigbear90560bigbear90560
提出日時 2015-07-02 21:00:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 3,472 ms
コンパイル使用メモリ 71,860 KB
実行使用メモリ 62,328 KB
最終ジャッジ日時 2023-09-22 05:41:41
合計ジャッジ時間 13,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,824 KB
testcase_01 AC 127 ms
55,888 KB
testcase_02 WA -
testcase_03 AC 236 ms
59,480 KB
testcase_04 AC 219 ms
56,980 KB
testcase_05 WA -
testcase_06 AC 225 ms
59,268 KB
testcase_07 AC 224 ms
59,120 KB
testcase_08 AC 236 ms
59,632 KB
testcase_09 AC 205 ms
58,584 KB
testcase_10 AC 258 ms
60,392 KB
testcase_11 AC 224 ms
59,380 KB
testcase_12 AC 246 ms
59,968 KB
testcase_13 AC 247 ms
59,988 KB
testcase_14 AC 143 ms
55,660 KB
testcase_15 WA -
testcase_16 AC 272 ms
62,328 KB
testcase_17 AC 264 ms
57,812 KB
testcase_18 AC 264 ms
60,144 KB
testcase_19 AC 283 ms
60,684 KB
testcase_20 AC 135 ms
55,924 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 138 ms
55,432 KB
testcase_24 AC 170 ms
56,192 KB
testcase_25 AC 206 ms
56,468 KB
testcase_26 AC 138 ms
55,548 KB
testcase_27 AC 140 ms
55,864 KB
testcase_28 AC 139 ms
55,796 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 130 ms
55,540 KB
testcase_32 AC 130 ms
55,412 KB
testcase_33 AC 128 ms
55,636 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) {
        		break;
        	} else {
        		resCount++;	
        	}
        }
        System.out.println(resCount);
	}

}
0