結果

問題 No.156 キャンディー・ボックス
ユーザー aikon_marimoaikon_marimo
提出日時 2018-01-30 00:15:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 72,044 KB
実行使用メモリ 57,160 KB
最終ジャッジ日時 2023-09-19 03:34:49
合計ジャッジ時間 8,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,884 KB
testcase_01 AC 125 ms
55,812 KB
testcase_02 AC 126 ms
55,692 KB
testcase_03 AC 126 ms
53,508 KB
testcase_04 AC 126 ms
55,388 KB
testcase_05 AC 128 ms
55,500 KB
testcase_06 AC 128 ms
55,624 KB
testcase_07 AC 128 ms
57,160 KB
testcase_08 AC 127 ms
55,616 KB
testcase_09 AC 125 ms
55,344 KB
testcase_10 AC 126 ms
55,792 KB
testcase_11 AC 129 ms
55,448 KB
testcase_12 AC 128 ms
55,444 KB
testcase_13 AC 125 ms
55,676 KB
testcase_14 AC 128 ms
55,320 KB
testcase_15 AC 127 ms
55,712 KB
testcase_16 AC 127 ms
55,764 KB
testcase_17 AC 127 ms
55,376 KB
testcase_18 AC 128 ms
55,744 KB
testcase_19 AC 127 ms
55,436 KB
testcase_20 AC 130 ms
55,568 KB
testcase_21 AC 127 ms
55,508 KB
testcase_22 AC 126 ms
55,632 KB
testcase_23 AC 126 ms
55,628 KB
testcase_24 AC 131 ms
55,508 KB
testcase_25 AC 126 ms
55,500 KB
testcase_26 AC 126 ms
55,440 KB
testcase_27 AC 126 ms
55,324 KB
testcase_28 AC 128 ms
55,812 KB
testcase_29 AC 129 ms
55,372 KB
testcase_30 AC 127 ms
55,548 KB
testcase_31 AC 129 ms
55,412 KB
testcase_32 AC 128 ms
55,756 KB
testcase_33 AC 128 ms
55,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.No156;

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N, M;
		List<Integer> arrC = new ArrayList<Integer>();
		
		N = in.nextInt();
		M = in.nextInt();
		for (int i = 0; i < N; i++) {
			int C = in.nextInt();
			arrC.add(C);
		}
		
		Collections.sort(arrC);
		
		int cnt = 0;
		int sum = 0;
		while (M > 0) {
			M -= arrC.get(cnt++);
		}
		if (M < 0) {
			cnt = cnt-1;
		}
		System.out.println(cnt);
	}
}
0