結果

問題 No.5 数字のブロック
ユーザー m4s4k1ch1m4s4k1ch1
提出日時 2015-05-28 00:39:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 3,551 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 52,576 KB
最終ジャッジ日時 2024-04-29 00:57:03
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
50,016 KB
testcase_01 AC 56 ms
50,272 KB
testcase_02 AC 54 ms
49,916 KB
testcase_03 AC 94 ms
51,732 KB
testcase_04 AC 74 ms
50,924 KB
testcase_05 AC 92 ms
52,380 KB
testcase_06 AC 80 ms
51,068 KB
testcase_07 AC 87 ms
50,808 KB
testcase_08 AC 92 ms
51,972 KB
testcase_09 AC 66 ms
50,560 KB
testcase_10 AC 104 ms
52,576 KB
testcase_11 AC 85 ms
50,980 KB
testcase_12 AC 91 ms
52,088 KB
testcase_13 AC 86 ms
51,472 KB
testcase_14 AC 54 ms
49,756 KB
testcase_15 AC 54 ms
50,000 KB
testcase_16 AC 95 ms
52,408 KB
testcase_17 AC 107 ms
52,196 KB
testcase_18 AC 104 ms
51,784 KB
testcase_19 AC 111 ms
52,296 KB
testcase_20 AC 55 ms
50,148 KB
testcase_21 AC 53 ms
50,152 KB
testcase_22 AC 57 ms
50,108 KB
testcase_23 AC 53 ms
50,100 KB
testcase_24 AC 56 ms
50,096 KB
testcase_25 AC 56 ms
50,056 KB
testcase_26 AC 54 ms
50,048 KB
testcase_27 AC 54 ms
49,728 KB
testcase_28 AC 54 ms
50,256 KB
testcase_29 AC 74 ms
51,588 KB
testcase_30 AC 65 ms
50,464 KB
testcase_31 AC 53 ms
50,192 KB
testcase_32 AC 52 ms
50,204 KB
testcase_33 AC 54 ms
50,120 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