結果

問題 No.5 数字のブロック
ユーザー enuo-9enuo-9
提出日時 2016-09-15 13:30:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 294 ms / 5,000 ms
コード長 949 bytes
コンパイル時間 3,859 ms
コンパイル使用メモリ 84,536 KB
実行使用メモリ 47,980 KB
最終ジャッジ日時 2024-04-29 07:59:08
合計ジャッジ時間 11,715 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,220 KB
testcase_01 AC 132 ms
41,100 KB
testcase_02 AC 130 ms
41,116 KB
testcase_03 AC 259 ms
47,056 KB
testcase_04 AC 241 ms
45,928 KB
testcase_05 AC 270 ms
47,076 KB
testcase_06 AC 245 ms
46,248 KB
testcase_07 AC 231 ms
45,744 KB
testcase_08 AC 250 ms
46,704 KB
testcase_09 AC 213 ms
43,504 KB
testcase_10 AC 283 ms
47,632 KB
testcase_11 AC 237 ms
45,784 KB
testcase_12 AC 256 ms
46,256 KB
testcase_13 AC 261 ms
45,848 KB
testcase_14 AC 146 ms
41,568 KB
testcase_15 AC 157 ms
41,528 KB
testcase_16 AC 274 ms
47,140 KB
testcase_17 AC 283 ms
47,864 KB
testcase_18 AC 285 ms
46,292 KB
testcase_19 AC 294 ms
47,980 KB
testcase_20 AC 129 ms
41,216 KB
testcase_21 AC 116 ms
39,944 KB
testcase_22 AC 128 ms
41,156 KB
testcase_23 AC 128 ms
41,404 KB
testcase_24 AC 168 ms
41,572 KB
testcase_25 AC 177 ms
41,848 KB
testcase_26 AC 121 ms
40,028 KB
testcase_27 AC 136 ms
41,388 KB
testcase_28 AC 129 ms
41,240 KB
testcase_29 AC 241 ms
46,108 KB
testcase_30 AC 210 ms
43,896 KB
testcase_31 AC 129 ms
41,260 KB
testcase_32 AC 121 ms
40,168 KB
testcase_33 AC 116 ms
40,364 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