結果

問題 No.5 数字のブロック
ユーザー Natsume-MNatsume-M
提出日時 2016-11-28 18:53:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 273 ms / 5,000 ms
コード長 353 bytes
コンパイル時間 4,535 ms
コンパイル使用メモリ 71,188 KB
実行使用メモリ 60,984 KB
最終ジャッジ日時 2023-08-11 16:55:52
合計ジャッジ時間 11,285 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,144 KB
testcase_01 AC 131 ms
55,808 KB
testcase_02 AC 128 ms
55,952 KB
testcase_03 AC 243 ms
59,572 KB
testcase_04 AC 219 ms
59,172 KB
testcase_05 AC 257 ms
59,940 KB
testcase_06 AC 232 ms
58,220 KB
testcase_07 AC 219 ms
59,548 KB
testcase_08 AC 238 ms
59,280 KB
testcase_09 AC 202 ms
58,700 KB
testcase_10 AC 250 ms
59,992 KB
testcase_11 AC 225 ms
59,696 KB
testcase_12 AC 238 ms
60,048 KB
testcase_13 AC 243 ms
59,752 KB
testcase_14 AC 145 ms
55,636 KB
testcase_15 AC 157 ms
55,824 KB
testcase_16 AC 246 ms
60,552 KB
testcase_17 AC 269 ms
60,548 KB
testcase_18 AC 260 ms
60,604 KB
testcase_19 AC 273 ms
60,984 KB
testcase_20 AC 129 ms
55,800 KB
testcase_21 AC 130 ms
55,816 KB
testcase_22 AC 129 ms
55,900 KB
testcase_23 AC 130 ms
55,804 KB
testcase_24 AC 157 ms
55,972 KB
testcase_25 AC 188 ms
56,980 KB
testcase_26 AC 127 ms
55,616 KB
testcase_27 AC 128 ms
55,792 KB
testcase_28 AC 127 ms
55,896 KB
testcase_29 AC 220 ms
59,500 KB
testcase_30 AC 204 ms
58,780 KB
testcase_31 AC 128 ms
56,024 KB
testcase_32 AC 127 ms
55,876 KB
testcase_33 AC 129 ms
56,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class y5 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, s = 0, l = sc.nextInt(), n = sc.nextInt();
		int[] w = new int[n];
		for (i=0; i<w.length; i++)	w[i] = sc.nextInt();
		Arrays.sort(w);
		for (i=0; i<w.length; i++) {
			s += w[i];
			if (s>l)	break;
		}
		System.out.println(i);
	}
}
0