結果

問題 No.5 数字のブロック
ユーザー 練習生練習生
提出日時 2015-08-15 17:54:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 5,000 ms
コード長 691 bytes
コンパイル時間 3,558 ms
コンパイル使用メモリ 73,844 KB
実行使用メモリ 47,052 KB
最終ジャッジ日時 2024-04-29 06:23:30
合計ジャッジ時間 11,497 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
41,056 KB
testcase_01 AC 128 ms
40,960 KB
testcase_02 AC 114 ms
39,968 KB
testcase_03 AC 235 ms
45,772 KB
testcase_04 AC 226 ms
45,292 KB
testcase_05 AC 253 ms
46,552 KB
testcase_06 AC 229 ms
45,792 KB
testcase_07 AC 224 ms
45,488 KB
testcase_08 AC 240 ms
45,844 KB
testcase_09 AC 205 ms
43,356 KB
testcase_10 AC 263 ms
46,860 KB
testcase_11 AC 218 ms
45,536 KB
testcase_12 AC 241 ms
45,548 KB
testcase_13 AC 249 ms
45,540 KB
testcase_14 AC 141 ms
41,376 KB
testcase_15 AC 163 ms
41,612 KB
testcase_16 AC 254 ms
45,896 KB
testcase_17 AC 267 ms
46,468 KB
testcase_18 AC 268 ms
46,240 KB
testcase_19 AC 268 ms
47,052 KB
testcase_20 AC 130 ms
41,248 KB
testcase_21 AC 133 ms
41,180 KB
testcase_22 AC 120 ms
40,976 KB
testcase_23 AC 127 ms
40,956 KB
testcase_24 AC 164 ms
41,780 KB
testcase_25 AC 196 ms
41,944 KB
testcase_26 AC 136 ms
41,124 KB
testcase_27 AC 141 ms
41,048 KB
testcase_28 AC 135 ms
41,324 KB
testcase_29 AC 232 ms
45,212 KB
testcase_30 AC 201 ms
43,468 KB
testcase_31 AC 129 ms
41,172 KB
testcase_32 AC 130 ms
41,088 KB
testcase_33 AC 127 ms
41,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No5 {
	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();
		}
		sc.close();
		// ブロックの中から最小のものを1つずつ探して箱に入れる
		int lin = 0;
		int count = 0;
		while(l >= lin){
			int min = l;
			int minIndex = 0;
			for(int i = 0; i < w.length; i++){
				if(w[i] < min){
					min = w[i];
					minIndex = i;
				}
			}
			lin = lin + min;
			w[minIndex] = l;
			count++;
		}
		count--;
		System.out.println(count);
	}
}
0