結果

問題 No.5 数字のブロック
ユーザー pao2pao2pao2pao2
提出日時 2022-07-30 07:37:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 256 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 2,604 ms
コンパイル使用メモリ 74,516 KB
実行使用メモリ 61,072 KB
最終ジャッジ日時 2023-09-27 08:19:58
合計ジャッジ時間 9,502 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,128 KB
testcase_01 AC 124 ms
56,232 KB
testcase_02 AC 121 ms
56,328 KB
testcase_03 AC 227 ms
59,384 KB
testcase_04 AC 210 ms
59,416 KB
testcase_05 AC 238 ms
59,748 KB
testcase_06 AC 222 ms
59,556 KB
testcase_07 AC 215 ms
59,944 KB
testcase_08 AC 228 ms
60,440 KB
testcase_09 AC 194 ms
58,284 KB
testcase_10 AC 240 ms
59,704 KB
testcase_11 AC 213 ms
59,592 KB
testcase_12 AC 237 ms
59,944 KB
testcase_13 AC 240 ms
60,300 KB
testcase_14 AC 136 ms
55,564 KB
testcase_15 AC 151 ms
56,520 KB
testcase_16 AC 244 ms
60,444 KB
testcase_17 AC 256 ms
61,072 KB
testcase_18 AC 250 ms
60,672 KB
testcase_19 AC 254 ms
60,720 KB
testcase_20 AC 120 ms
56,224 KB
testcase_21 AC 120 ms
56,268 KB
testcase_22 AC 119 ms
55,848 KB
testcase_23 AC 119 ms
56,240 KB
testcase_24 AC 143 ms
56,516 KB
testcase_25 AC 164 ms
56,940 KB
testcase_26 AC 120 ms
56,432 KB
testcase_27 AC 120 ms
56,148 KB
testcase_28 AC 120 ms
56,164 KB
testcase_29 AC 208 ms
59,656 KB
testcase_30 AC 195 ms
58,936 KB
testcase_31 AC 121 ms
56,544 KB
testcase_32 AC 122 ms
56,116 KB
testcase_33 AC 120 ms
56,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	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];
		Arrays.setAll(w, i -> sc.nextInt());
		Arrays.sort(w);

		int cnt = 0;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += w[i];
			if (sum <= l) ++cnt;
		}

		System.out.println(cnt);

		sc.close();
	}
}
0