結果

問題 No.5 数字のブロック
ユーザー barrett114514barrett114514
提出日時 2017-07-21 23:24:49
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 473 bytes
コンパイル時間 4,494 ms
コンパイル使用メモリ 75,564 KB
実行使用メモリ 59,124 KB
最終ジャッジ日時 2024-04-17 10:40:06
合計ジャッジ時間 10,814 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
54,220 KB
testcase_01 AC 116 ms
53,124 KB
testcase_02 AC 125 ms
53,984 KB
testcase_03 AC 235 ms
58,188 KB
testcase_04 AC 222 ms
57,748 KB
testcase_05 AC 254 ms
58,932 KB
testcase_06 AC 230 ms
57,724 KB
testcase_07 AC 222 ms
57,532 KB
testcase_08 AC 242 ms
58,068 KB
testcase_09 AC 203 ms
56,884 KB
testcase_10 AC 257 ms
58,740 KB
testcase_11 AC 225 ms
57,956 KB
testcase_12 AC 235 ms
58,444 KB
testcase_13 AC 254 ms
59,084 KB
testcase_14 AC 141 ms
54,236 KB
testcase_15 AC 154 ms
54,232 KB
testcase_16 AC 255 ms
58,184 KB
testcase_17 AC 261 ms
58,908 KB
testcase_18 AC 266 ms
58,984 KB
testcase_19 AC 266 ms
59,124 KB
testcase_20 RE -
testcase_21 AC 129 ms
53,984 KB
testcase_22 AC 129 ms
54,208 KB
testcase_23 AC 116 ms
53,016 KB
testcase_24 AC 171 ms
54,372 KB
testcase_25 AC 181 ms
54,580 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 220 ms
57,284 KB
testcase_30 AC 205 ms
56,452 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class NumberBlocks {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int N = sc.nextInt();
		int W[] = new int[N];
		
		for(int i = 0;i < N; i++){
			W[i] = sc.nextInt();
		}
		Arrays.sort(W);
		
		for(int i = 0;L > 0;){
			L -= W[i];
			i ++;

			if(L <= 0){
				if(L < 0){
				i = i - 1;
				}
				
				System.out.println(i);
				break;
			}
		}

	}

}
0