結果

問題 No.5 数字のブロック
ユーザー 練習生練習生
提出日時 2015-08-15 17:48:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 3,259 ms
コンパイル使用メモリ 72,788 KB
実行使用メモリ 59,896 KB
最終ジャッジ日時 2023-09-25 12:09:59
合計ジャッジ時間 11,218 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,784 KB
testcase_01 AC 127 ms
55,464 KB
testcase_02 WA -
testcase_03 AC 230 ms
59,252 KB
testcase_04 AC 211 ms
59,012 KB
testcase_05 WA -
testcase_06 AC 213 ms
59,096 KB
testcase_07 AC 219 ms
58,804 KB
testcase_08 AC 214 ms
58,888 KB
testcase_09 AC 197 ms
58,200 KB
testcase_10 AC 243 ms
59,288 KB
testcase_11 AC 214 ms
58,616 KB
testcase_12 AC 231 ms
59,504 KB
testcase_13 AC 240 ms
59,196 KB
testcase_14 AC 137 ms
55,876 KB
testcase_15 WA -
testcase_16 AC 238 ms
59,128 KB
testcase_17 AC 252 ms
59,408 KB
testcase_18 AC 251 ms
59,600 KB
testcase_19 AC 256 ms
59,896 KB
testcase_20 AC 123 ms
55,748 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 125 ms
55,836 KB
testcase_24 AC 151 ms
55,944 KB
testcase_25 AC 176 ms
54,248 KB
testcase_26 AC 121 ms
55,424 KB
testcase_27 AC 121 ms
56,268 KB
testcase_28 AC 121 ms
55,652 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 125 ms
55,896 KB
testcase_32 AC 125 ms
55,864 KB
testcase_33 AC 120 ms
56,032 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