結果

問題 No.5 数字のブロック
ユーザー suiginginsuigingin
提出日時 2015-07-07 01:24:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 255 ms / 5,000 ms
コード長 495 bytes
コンパイル時間 3,992 ms
コンパイル使用メモリ 72,220 KB
実行使用メモリ 60,656 KB
最終ジャッジ日時 2023-08-11 08:30:54
合計ジャッジ時間 10,655 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,032 KB
testcase_01 AC 124 ms
55,716 KB
testcase_02 AC 123 ms
56,132 KB
testcase_03 AC 213 ms
59,360 KB
testcase_04 AC 209 ms
59,180 KB
testcase_05 AC 241 ms
60,352 KB
testcase_06 AC 224 ms
59,840 KB
testcase_07 AC 210 ms
57,396 KB
testcase_08 AC 226 ms
59,052 KB
testcase_09 AC 196 ms
59,100 KB
testcase_10 AC 239 ms
59,580 KB
testcase_11 AC 214 ms
59,592 KB
testcase_12 AC 231 ms
59,708 KB
testcase_13 AC 239 ms
59,788 KB
testcase_14 AC 134 ms
55,704 KB
testcase_15 AC 159 ms
56,372 KB
testcase_16 AC 237 ms
60,060 KB
testcase_17 AC 250 ms
60,656 KB
testcase_18 AC 248 ms
60,380 KB
testcase_19 AC 255 ms
60,348 KB
testcase_20 AC 123 ms
56,056 KB
testcase_21 AC 125 ms
55,700 KB
testcase_22 AC 123 ms
55,856 KB
testcase_23 AC 123 ms
55,788 KB
testcase_24 AC 146 ms
56,056 KB
testcase_25 AC 177 ms
56,172 KB
testcase_26 AC 123 ms
55,716 KB
testcase_27 AC 123 ms
56,000 KB
testcase_28 AC 121 ms
55,504 KB
testcase_29 AC 213 ms
58,632 KB
testcase_30 AC 198 ms
58,424 KB
testcase_31 AC 123 ms
55,696 KB
testcase_32 AC 122 ms
55,908 KB
testcase_33 AC 124 ms
55,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No_005 {
	Scanner sc = new Scanner(System.in);

	void run() {
		int L = sc.nextInt();
		int N = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int sum = 0;
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (sum + a[i] <= L) sum += a[i];
			else break;
			cnt++;
		}
		System.out.println(cnt);
	}

	public static void main(String[] args) {
		new No_005().run();
	}
}
0