結果

問題 No.5 数字のブロック
ユーザー m4s4k1ch1m4s4k1ch1
提出日時 2015-05-28 00:39:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 3,062 ms
コンパイル使用メモリ 71,644 KB
実行使用メモリ 53,272 KB
最終ジャッジ日時 2023-08-11 08:23:09
合計ジャッジ時間 6,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,572 KB
testcase_01 AC 45 ms
49,512 KB
testcase_02 AC 45 ms
49,372 KB
testcase_03 AC 81 ms
52,864 KB
testcase_04 AC 67 ms
51,240 KB
testcase_05 AC 92 ms
52,648 KB
testcase_06 AC 75 ms
52,584 KB
testcase_07 AC 66 ms
51,240 KB
testcase_08 AC 73 ms
51,988 KB
testcase_09 AC 58 ms
50,956 KB
testcase_10 AC 94 ms
52,380 KB
testcase_11 AC 69 ms
51,840 KB
testcase_12 AC 87 ms
52,824 KB
testcase_13 AC 93 ms
53,272 KB
testcase_14 AC 47 ms
49,280 KB
testcase_15 AC 48 ms
49,576 KB
testcase_16 AC 96 ms
52,900 KB
testcase_17 AC 95 ms
52,812 KB
testcase_18 AC 97 ms
52,872 KB
testcase_19 AC 98 ms
52,944 KB
testcase_20 AC 45 ms
49,228 KB
testcase_21 AC 46 ms
49,576 KB
testcase_22 AC 47 ms
49,684 KB
testcase_23 AC 46 ms
49,260 KB
testcase_24 AC 54 ms
49,520 KB
testcase_25 AC 51 ms
49,608 KB
testcase_26 AC 48 ms
49,192 KB
testcase_27 AC 46 ms
49,324 KB
testcase_28 AC 45 ms
49,420 KB
testcase_29 AC 65 ms
51,812 KB
testcase_30 AC 58 ms
50,244 KB
testcase_31 AC 45 ms
49,328 KB
testcase_32 AC 46 ms
49,520 KB
testcase_33 AC 45 ms
49,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int l = Integer.parseInt(line);
		line = br.readLine();
		int n = Integer.parseInt(line);
		line = br.readLine();
		String[] lines = line.split(" ");
		int[] ws = new int[n]; 
		
		for (int t = 0; t < n; t++) {
			ws[t] = Integer.parseInt(lines[t]);
		}
		
		Arrays.sort(ws);

		int total = 0;
		int res = 0;
		for (int w : ws) {
			if ((total + w) > l) {
				break;
			}
			total += w;
			res++;
		}
		System.out.println(res);
	}
}
0