結果

問題 No.5 数字のブロック
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-13 19:33:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 283 ms / 5,000 ms
コード長 400 bytes
コンパイル時間 3,234 ms
コンパイル使用メモリ 74,864 KB
実行使用メモリ 47,580 KB
最終ジャッジ日時 2024-04-29 10:16:10
合計ジャッジ時間 9,925 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,240 KB
testcase_01 AC 122 ms
39,928 KB
testcase_02 AC 135 ms
41,204 KB
testcase_03 AC 250 ms
46,052 KB
testcase_04 AC 227 ms
45,984 KB
testcase_05 AC 270 ms
46,008 KB
testcase_06 AC 235 ms
46,072 KB
testcase_07 AC 234 ms
45,612 KB
testcase_08 AC 247 ms
45,928 KB
testcase_09 AC 208 ms
43,788 KB
testcase_10 AC 265 ms
46,956 KB
testcase_11 AC 227 ms
46,096 KB
testcase_12 AC 245 ms
46,428 KB
testcase_13 AC 265 ms
47,168 KB
testcase_14 AC 147 ms
41,244 KB
testcase_15 AC 171 ms
41,892 KB
testcase_16 AC 274 ms
47,184 KB
testcase_17 AC 283 ms
47,532 KB
testcase_18 AC 269 ms
46,980 KB
testcase_19 AC 278 ms
47,580 KB
testcase_20 AC 133 ms
41,168 KB
testcase_21 AC 132 ms
41,152 KB
testcase_22 AC 131 ms
41,228 KB
testcase_23 AC 130 ms
41,492 KB
testcase_24 AC 154 ms
41,700 KB
testcase_25 AC 180 ms
41,752 KB
testcase_26 AC 131 ms
41,004 KB
testcase_27 AC 130 ms
41,244 KB
testcase_28 AC 117 ms
40,428 KB
testcase_29 AC 217 ms
45,664 KB
testcase_30 AC 207 ms
43,528 KB
testcase_31 AC 130 ms
41,372 KB
testcase_32 AC 129 ms
41,420 KB
testcase_33 AC 133 ms
41,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int l = sc.nextInt();
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = sc.nextInt();
		Arrays.sort(ar);
		int ans = 0;
		for (int i=0; i<n; i++) {
			if (l-ar[i] >= 0) {
				l -= ar[i];
				ans++;
			}
		}
		System.out.println(ans);
		
	}
}
0