結果

問題 No.5 数字のブロック
ユーザー suiginginsuigingin
提出日時 2015-07-07 01:24:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 282 ms / 5,000 ms
コード長 495 bytes
コンパイル時間 3,669 ms
コンパイル使用メモリ 75,008 KB
実行使用メモリ 47,996 KB
最終ジャッジ日時 2024-04-29 01:03:58
合計ジャッジ時間 11,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,468 KB
testcase_01 AC 130 ms
41,288 KB
testcase_02 AC 129 ms
41,428 KB
testcase_03 AC 247 ms
46,512 KB
testcase_04 AC 223 ms
45,524 KB
testcase_05 AC 253 ms
46,780 KB
testcase_06 AC 236 ms
46,300 KB
testcase_07 AC 228 ms
45,640 KB
testcase_08 AC 246 ms
46,764 KB
testcase_09 AC 208 ms
43,624 KB
testcase_10 AC 267 ms
47,328 KB
testcase_11 AC 234 ms
46,312 KB
testcase_12 AC 251 ms
46,592 KB
testcase_13 AC 259 ms
47,140 KB
testcase_14 AC 145 ms
41,456 KB
testcase_15 AC 152 ms
41,500 KB
testcase_16 AC 261 ms
47,212 KB
testcase_17 AC 272 ms
47,388 KB
testcase_18 AC 269 ms
47,728 KB
testcase_19 AC 282 ms
47,996 KB
testcase_20 AC 135 ms
41,372 KB
testcase_21 AC 133 ms
41,160 KB
testcase_22 AC 132 ms
41,644 KB
testcase_23 AC 134 ms
41,264 KB
testcase_24 AC 169 ms
42,204 KB
testcase_25 AC 183 ms
41,948 KB
testcase_26 AC 135 ms
41,536 KB
testcase_27 AC 133 ms
41,348 KB
testcase_28 AC 131 ms
41,428 KB
testcase_29 AC 225 ms
45,384 KB
testcase_30 AC 207 ms
44,136 KB
testcase_31 AC 132 ms
41,648 KB
testcase_32 AC 134 ms
41,504 KB
testcase_33 AC 133 ms
41,024 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