結果

問題 No.5 数字のブロック
ユーザー koukonkokoukonko
提出日時 2015-12-07 11:01:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 175 ms / 5,000 ms
コード長 868 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 73,412 KB
実行使用メモリ 52,720 KB
最終ジャッジ日時 2023-08-11 14:24:55
合計ジャッジ時間 6,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,344 KB
testcase_01 AC 39 ms
49,104 KB
testcase_02 AC 40 ms
49,216 KB
testcase_03 AC 110 ms
51,896 KB
testcase_04 AC 83 ms
51,612 KB
testcase_05 AC 134 ms
52,256 KB
testcase_06 AC 99 ms
51,612 KB
testcase_07 AC 83 ms
51,728 KB
testcase_08 AC 113 ms
51,524 KB
testcase_09 AC 75 ms
51,560 KB
testcase_10 AC 147 ms
51,804 KB
testcase_11 AC 81 ms
51,192 KB
testcase_12 AC 110 ms
51,944 KB
testcase_13 AC 141 ms
52,720 KB
testcase_14 AC 43 ms
49,072 KB
testcase_15 AC 44 ms
49,108 KB
testcase_16 AC 138 ms
52,160 KB
testcase_17 AC 158 ms
52,512 KB
testcase_18 AC 161 ms
52,032 KB
testcase_19 AC 175 ms
51,980 KB
testcase_20 AC 41 ms
49,016 KB
testcase_21 AC 42 ms
49,060 KB
testcase_22 AC 43 ms
49,128 KB
testcase_23 AC 42 ms
47,360 KB
testcase_24 AC 43 ms
49,120 KB
testcase_25 AC 58 ms
51,236 KB
testcase_26 AC 40 ms
48,940 KB
testcase_27 AC 41 ms
49,104 KB
testcase_28 AC 41 ms
49,268 KB
testcase_29 AC 82 ms
51,720 KB
testcase_30 AC 76 ms
51,524 KB
testcase_31 AC 40 ms
48,968 KB
testcase_32 AC 40 ms
49,280 KB
testcase_33 AC 40 ms
49,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

		try {
			int L = Integer.parseInt(buff.readLine());
			int N = Integer.parseInt(buff.readLine());
			int[] box = new int[N];
			String[] str = buff.readLine().split(" ");

			for (int i = 0; i < N; ++i) {
				box[i] = Integer.parseInt(str[i]);
				for (int j = 0; j < i; ++j) {
					if (box[i] < box[j]) {
						int w = box[i];
						box[i] = box[j];
						box[j] = w;
					}
				}
			}
			int ans = 0;
			int sum = 0;
			for (int i = 0; i < N; ++i) {
				sum += box[i];
				if (sum > L) {
					break;
				}
				++ans;
			}

			System.out.println(ans);
		} catch (NumberFormatException e) {

		} catch (IOException e) {

		}
	}
}
0