結果

問題 No.156 キャンディー・ボックス
ユーザー ffmm00ffmm00
提出日時 2015-06-10 20:21:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 4,018 ms
コンパイル使用メモリ 72,620 KB
実行使用メモリ 56,224 KB
最終ジャッジ日時 2023-09-18 19:37:52
合計ジャッジ時間 9,498 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,944 KB
testcase_01 AC 124 ms
55,796 KB
testcase_02 AC 126 ms
55,888 KB
testcase_03 AC 125 ms
55,876 KB
testcase_04 AC 128 ms
55,908 KB
testcase_05 AC 125 ms
56,100 KB
testcase_06 AC 126 ms
55,796 KB
testcase_07 AC 125 ms
55,904 KB
testcase_08 AC 125 ms
55,780 KB
testcase_09 AC 123 ms
56,200 KB
testcase_10 AC 127 ms
55,788 KB
testcase_11 AC 124 ms
56,224 KB
testcase_12 AC 127 ms
53,804 KB
testcase_13 AC 125 ms
55,916 KB
testcase_14 AC 126 ms
55,900 KB
testcase_15 AC 125 ms
56,140 KB
testcase_16 AC 125 ms
55,820 KB
testcase_17 AC 125 ms
55,912 KB
testcase_18 AC 128 ms
55,764 KB
testcase_19 AC 128 ms
55,768 KB
testcase_20 AC 127 ms
55,820 KB
testcase_21 AC 126 ms
55,908 KB
testcase_22 AC 127 ms
55,780 KB
testcase_23 AC 128 ms
55,828 KB
testcase_24 AC 125 ms
55,572 KB
testcase_25 AC 126 ms
56,076 KB
testcase_26 AC 127 ms
56,100 KB
testcase_27 AC 123 ms
55,600 KB
testcase_28 AC 125 ms
55,844 KB
testcase_29 AC 123 ms
55,556 KB
testcase_30 AC 126 ms
55,908 KB
testcase_31 AC 126 ms
55,856 KB
testcase_32 AC 126 ms
55,640 KB
testcase_33 AC 125 ms
55,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class N156 {

	public static void main(String[] args) {

		Scanner sca = new Scanner(System.in);

		int n = sca.nextInt();
		int m = sca.nextInt();

		int[] c = new int[n];

		for (int i = 0; i < n; i++)
			c[i] = sca.nextInt();

		Arrays.sort(c);

		int A = 0;

		for (int i = 0; i < n; i++) {
			m -= c[i];
			if (m < 0)
				break;
			A++;
		}

		System.out.println(A);

	}

}
0