結果

問題 No.5 数字のブロック
ユーザー bigbear90560bigbear90560
提出日時 2015-07-03 00:42:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 3,405 ms
コンパイル使用メモリ 72,304 KB
実行使用メモリ 61,052 KB
最終ジャッジ日時 2023-09-22 05:49:14
合計ジャッジ時間 11,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,776 KB
testcase_01 AC 127 ms
55,796 KB
testcase_02 WA -
testcase_03 AC 241 ms
60,464 KB
testcase_04 AC 226 ms
58,848 KB
testcase_05 WA -
testcase_06 AC 233 ms
60,388 KB
testcase_07 AC 219 ms
59,156 KB
testcase_08 AC 232 ms
59,624 KB
testcase_09 AC 198 ms
56,960 KB
testcase_10 AC 253 ms
59,908 KB
testcase_11 AC 224 ms
59,540 KB
testcase_12 AC 244 ms
59,884 KB
testcase_13 AC 246 ms
60,148 KB
testcase_14 AC 140 ms
55,752 KB
testcase_15 WA -
testcase_16 AC 251 ms
59,880 KB
testcase_17 AC 257 ms
60,748 KB
testcase_18 AC 258 ms
60,784 KB
testcase_19 AC 271 ms
61,052 KB
testcase_20 AC 130 ms
55,680 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 128 ms
55,980 KB
testcase_24 AC 154 ms
56,248 KB
testcase_25 AC 187 ms
55,024 KB
testcase_26 AC 125 ms
55,884 KB
testcase_27 AC 125 ms
56,016 KB
testcase_28 AC 124 ms
55,448 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 125 ms
55,640 KB
testcase_32 AC 126 ms
55,656 KB
testcase_33 AC 125 ms
55,748 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