結果

問題 No.5 数字のブロック
ユーザー kano_townkano_town
提出日時 2014-11-21 19:15:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 269 ms / 5,000 ms
コード長 456 bytes
コンパイル時間 4,233 ms
コンパイル使用メモリ 73,300 KB
実行使用メモリ 60,848 KB
最終ジャッジ日時 2023-08-11 07:56:21
合計ジャッジ時間 11,179 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,768 KB
testcase_01 AC 126 ms
55,712 KB
testcase_02 AC 126 ms
55,900 KB
testcase_03 AC 237 ms
59,532 KB
testcase_04 AC 218 ms
59,016 KB
testcase_05 AC 252 ms
59,868 KB
testcase_06 AC 229 ms
59,180 KB
testcase_07 AC 222 ms
59,356 KB
testcase_08 AC 231 ms
59,432 KB
testcase_09 AC 200 ms
58,188 KB
testcase_10 AC 245 ms
60,256 KB
testcase_11 AC 216 ms
59,896 KB
testcase_12 AC 225 ms
59,968 KB
testcase_13 AC 245 ms
60,312 KB
testcase_14 AC 137 ms
56,196 KB
testcase_15 AC 155 ms
54,080 KB
testcase_16 AC 247 ms
60,300 KB
testcase_17 AC 269 ms
60,848 KB
testcase_18 AC 260 ms
60,560 KB
testcase_19 AC 258 ms
60,640 KB
testcase_20 AC 126 ms
53,840 KB
testcase_21 AC 124 ms
55,876 KB
testcase_22 AC 124 ms
55,836 KB
testcase_23 AC 124 ms
55,796 KB
testcase_24 AC 150 ms
56,248 KB
testcase_25 AC 179 ms
56,168 KB
testcase_26 AC 125 ms
55,736 KB
testcase_27 AC 126 ms
55,916 KB
testcase_28 AC 125 ms
55,932 KB
testcase_29 AC 215 ms
59,364 KB
testcase_30 AC 200 ms
58,732 KB
testcase_31 AC 125 ms
55,552 KB
testcase_32 AC 124 ms
55,820 KB
testcase_33 AC 122 ms
55,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Yukicoder05 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int N = sc.nextInt();
		int[] W = new int[N];
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		Arrays.sort(W);
		
		int i, sum = 0;
		for (i = 0; i < N; i++) {
			sum += W[i];
			if (sum > L) break;
		}
		System.out.println(i);
	}
}
0