結果

問題 No.5 数字のブロック
ユーザー 練習生練習生
提出日時 2015-08-15 17:54:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 247 ms / 5,000 ms
コード長 691 bytes
コンパイル時間 5,507 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 60,460 KB
最終ジャッジ日時 2023-08-11 14:04:27
合計ジャッジ時間 10,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,700 KB
testcase_01 AC 117 ms
55,460 KB
testcase_02 AC 118 ms
55,508 KB
testcase_03 AC 222 ms
59,368 KB
testcase_04 AC 202 ms
58,912 KB
testcase_05 AC 225 ms
59,656 KB
testcase_06 AC 212 ms
59,552 KB
testcase_07 AC 208 ms
58,968 KB
testcase_08 AC 211 ms
57,632 KB
testcase_09 AC 187 ms
58,340 KB
testcase_10 AC 228 ms
59,804 KB
testcase_11 AC 207 ms
58,988 KB
testcase_12 AC 221 ms
59,544 KB
testcase_13 AC 228 ms
59,344 KB
testcase_14 AC 126 ms
55,732 KB
testcase_15 AC 136 ms
56,036 KB
testcase_16 AC 233 ms
59,896 KB
testcase_17 AC 247 ms
59,636 KB
testcase_18 AC 243 ms
60,088 KB
testcase_19 AC 241 ms
60,460 KB
testcase_20 AC 118 ms
56,088 KB
testcase_21 AC 118 ms
55,976 KB
testcase_22 AC 119 ms
56,384 KB
testcase_23 AC 116 ms
56,040 KB
testcase_24 AC 142 ms
56,012 KB
testcase_25 AC 170 ms
56,008 KB
testcase_26 AC 121 ms
55,736 KB
testcase_27 AC 119 ms
55,712 KB
testcase_28 AC 118 ms
55,712 KB
testcase_29 AC 202 ms
59,188 KB
testcase_30 AC 188 ms
58,504 KB
testcase_31 AC 117 ms
56,028 KB
testcase_32 AC 118 ms
55,680 KB
testcase_33 AC 117 ms
55,712 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