結果

問題 No.5 数字のブロック
ユーザー HaleakalaHaleakala
提出日時 2018-02-18 22:47:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 3,353 ms
コンパイル使用メモリ 72,796 KB
実行使用メモリ 60,148 KB
最終ジャッジ日時 2023-09-18 02:28:14
合計ジャッジ時間 10,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,860 KB
testcase_01 AC 121 ms
55,740 KB
testcase_02 WA -
testcase_03 AC 192 ms
59,328 KB
testcase_04 AC 181 ms
59,000 KB
testcase_05 AC 218 ms
60,028 KB
testcase_06 AC 189 ms
59,268 KB
testcase_07 AC 183 ms
58,856 KB
testcase_08 AC 203 ms
58,380 KB
testcase_09 AC 178 ms
55,988 KB
testcase_10 AC 211 ms
60,148 KB
testcase_11 AC 183 ms
59,248 KB
testcase_12 AC 196 ms
59,384 KB
testcase_13 AC 213 ms
59,948 KB
testcase_14 AC 130 ms
56,208 KB
testcase_15 AC 139 ms
56,052 KB
testcase_16 AC 209 ms
59,752 KB
testcase_17 AC 222 ms
59,776 KB
testcase_18 AC 217 ms
59,988 KB
testcase_19 AC 225 ms
59,728 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 118 ms
56,024 KB
testcase_24 AC 141 ms
55,776 KB
testcase_25 AC 171 ms
55,728 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 188 ms
58,084 KB
testcase_30 AC 185 ms
56,568 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Answer {
	public static void main(String str[]) {
        Scanner sc = new Scanner(System.in);

        int width = Integer.valueOf(sc.nextLine());
        int blockNum = Integer.valueOf(sc.nextLine());

        int blocks[] = new int[blockNum];
        for(int i=0; i<blockNum; i++) {
        	blocks[i] = Integer.valueOf(sc.next());
        }

        Arrays.sort(blocks);

        for(int i=0; i<blockNum; i++) {
        	if(width < blocks[i]) {
        		System.out.println(i);
        		break;
        	}
        	width -= blocks[i];
        }
	}
}
0