結果

問題 No.5 数字のブロック
ユーザー AAAR SalmonAAAR Salmon
提出日時 2021-04-02 14:34:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 6,073 ms
コンパイル使用メモリ 74,852 KB
実行使用メモリ 60,736 KB
最終ジャッジ日時 2023-08-24 22:52:27
合計ジャッジ時間 13,993 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,772 KB
testcase_01 AC 124 ms
56,004 KB
testcase_02 AC 123 ms
56,292 KB
testcase_03 AC 226 ms
59,624 KB
testcase_04 AC 206 ms
58,556 KB
testcase_05 AC 243 ms
60,080 KB
testcase_06 AC 222 ms
59,656 KB
testcase_07 AC 215 ms
59,280 KB
testcase_08 AC 229 ms
60,212 KB
testcase_09 AC 196 ms
58,440 KB
testcase_10 AC 244 ms
60,156 KB
testcase_11 AC 216 ms
59,800 KB
testcase_12 AC 237 ms
59,872 KB
testcase_13 AC 231 ms
60,360 KB
testcase_14 AC 134 ms
55,844 KB
testcase_15 AC 146 ms
55,560 KB
testcase_16 AC 241 ms
60,092 KB
testcase_17 AC 247 ms
60,260 KB
testcase_18 AC 252 ms
60,648 KB
testcase_19 AC 254 ms
60,736 KB
testcase_20 AC 122 ms
55,784 KB
testcase_21 AC 122 ms
55,652 KB
testcase_22 AC 122 ms
56,140 KB
testcase_23 AC 123 ms
55,976 KB
testcase_24 AC 153 ms
56,196 KB
testcase_25 AC 169 ms
56,516 KB
testcase_26 AC 122 ms
55,764 KB
testcase_27 AC 122 ms
56,152 KB
testcase_28 AC 122 ms
55,948 KB
testcase_29 AC 207 ms
59,136 KB
testcase_30 AC 199 ms
60,492 KB
testcase_31 AC 123 ms
55,704 KB
testcase_32 AC 124 ms
55,952 KB
testcase_33 AC 122 ms
56,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

		int ans = 0;
		for (int i = 0; i < N; i++) {
			if (L >= W[i]) {
				L -= W[i];
				ans++;
			}
		}
		System.out.println(ans);
	}
}
0