結果

問題 No.156 キャンディー・ボックス
ユーザー r.suzukir.suzuki
提出日時 2015-12-29 15:19:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 4,237 ms
コンパイル使用メモリ 73,944 KB
実行使用メモリ 55,988 KB
最終ジャッジ日時 2023-09-19 03:04:26
合計ジャッジ時間 10,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,784 KB
testcase_01 AC 130 ms
55,536 KB
testcase_02 AC 134 ms
55,584 KB
testcase_03 AC 132 ms
55,924 KB
testcase_04 AC 131 ms
55,488 KB
testcase_05 AC 129 ms
55,464 KB
testcase_06 AC 130 ms
55,796 KB
testcase_07 AC 130 ms
55,384 KB
testcase_08 AC 130 ms
55,576 KB
testcase_09 AC 134 ms
55,488 KB
testcase_10 AC 132 ms
55,704 KB
testcase_11 AC 132 ms
55,192 KB
testcase_12 AC 128 ms
55,988 KB
testcase_13 AC 129 ms
55,196 KB
testcase_14 AC 130 ms
55,640 KB
testcase_15 AC 128 ms
55,372 KB
testcase_16 AC 132 ms
55,544 KB
testcase_17 AC 129 ms
55,220 KB
testcase_18 AC 132 ms
55,480 KB
testcase_19 AC 132 ms
55,548 KB
testcase_20 AC 131 ms
55,640 KB
testcase_21 AC 131 ms
55,488 KB
testcase_22 AC 133 ms
55,484 KB
testcase_23 AC 131 ms
55,748 KB
testcase_24 AC 129 ms
55,480 KB
testcase_25 AC 128 ms
55,256 KB
testcase_26 AC 132 ms
55,228 KB
testcase_27 AC 132 ms
55,384 KB
testcase_28 AC 130 ms
55,264 KB
testcase_29 AC 128 ms
55,324 KB
testcase_30 AC 130 ms
55,340 KB
testcase_31 AC 131 ms
55,240 KB
testcase_32 AC 130 ms
55,640 KB
testcase_33 AC 129 ms
55,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.LinkedList;

class A {
	int want;
	LinkedList<Integer> have = new LinkedList<Integer>();

	A(int i) {
		this.want = i;
	}

}

public class No_156 {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int n = sc.nextInt();
		LinkedList<Integer> box = new LinkedList<Integer>();
		A a = new A(sc.nextInt());

		for (int i = 0; i < n; i++) {
			box.add(sc.nextInt());
		}

		java.util.Collections.sort(box);

		while (a.want > 0) {
			int x = box.poll();
			a.want -= x;
			if (a.want >= 0) {
				a.have.add(x);
			}
		}
		System.out.println(a.have.size());
		sc.close();

	}

}
0