結果

問題 No.5 数字のブロック
ユーザー enuo-9enuo-9
提出日時 2016-09-15 13:30:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 281 ms / 5,000 ms
コード長 949 bytes
コンパイル時間 6,083 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 61,180 KB
最終ジャッジ日時 2023-08-11 16:01:36
合計ジャッジ時間 14,348 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,492 KB
testcase_01 AC 129 ms
55,956 KB
testcase_02 AC 126 ms
55,528 KB
testcase_03 AC 247 ms
60,368 KB
testcase_04 AC 217 ms
59,028 KB
testcase_05 AC 264 ms
60,428 KB
testcase_06 AC 236 ms
59,724 KB
testcase_07 AC 228 ms
59,288 KB
testcase_08 AC 239 ms
59,608 KB
testcase_09 AC 208 ms
58,228 KB
testcase_10 AC 272 ms
61,180 KB
testcase_11 AC 217 ms
59,824 KB
testcase_12 AC 244 ms
59,680 KB
testcase_13 AC 255 ms
60,264 KB
testcase_14 AC 140 ms
55,868 KB
testcase_15 AC 155 ms
55,908 KB
testcase_16 AC 260 ms
60,152 KB
testcase_17 AC 277 ms
60,340 KB
testcase_18 AC 280 ms
60,352 KB
testcase_19 AC 281 ms
60,340 KB
testcase_20 AC 136 ms
55,652 KB
testcase_21 AC 126 ms
55,488 KB
testcase_22 AC 125 ms
55,496 KB
testcase_23 AC 126 ms
55,872 KB
testcase_24 AC 153 ms
55,668 KB
testcase_25 AC 187 ms
56,128 KB
testcase_26 AC 127 ms
55,568 KB
testcase_27 AC 128 ms
55,564 KB
testcase_28 AC 126 ms
55,576 KB
testcase_29 AC 228 ms
60,104 KB
testcase_30 AC 196 ms
58,388 KB
testcase_31 AC 128 ms
55,612 KB
testcase_32 AC 127 ms
55,536 KB
testcase_33 AC 126 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class No5 {
	public static void main(String args[]){
		String str = "";
		int boxSize = 0;
		int blockQuantity = 0;
		ArrayList<Integer> blockSize = new ArrayList<Integer>();

		Scanner sc = new Scanner(System.in);

		BufferedReader input =
				new BufferedReader (new InputStreamReader (System.in));

			//str = input.readLine();
			boxSize = sc.nextInt();

			//str = input.readLine();
			blockQuantity = sc.nextInt();

			for(int i = 0; i < blockQuantity; i++){
				blockSize.add(sc.nextInt());
			};

			Collections.sort(blockSize);

			int cnt = 0;
			while(true){

				boxSize = boxSize - blockSize.get(cnt);

				if(boxSize < 0 || boxSize == 0){
					if(boxSize==0)
						cnt++;
					break;

				}
				cnt++;
				if(blockQuantity==cnt){break;}

			}

			System.out.println(cnt);

	}
}
0