結果

問題 No.156 キャンディー・ボックス
ユーザー ぴろずぴろず
提出日時 2015-02-26 23:26:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 3,137 ms
コンパイル使用メモリ 72,156 KB
実行使用メモリ 56,404 KB
最終ジャッジ日時 2023-09-18 18:43:08
合計ジャッジ時間 8,215 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,604 KB
testcase_01 AC 129 ms
56,404 KB
testcase_02 AC 127 ms
55,756 KB
testcase_03 AC 128 ms
56,072 KB
testcase_04 AC 126 ms
56,088 KB
testcase_05 AC 128 ms
55,604 KB
testcase_06 AC 130 ms
55,752 KB
testcase_07 AC 128 ms
55,844 KB
testcase_08 AC 130 ms
55,752 KB
testcase_09 AC 131 ms
56,132 KB
testcase_10 AC 128 ms
55,780 KB
testcase_11 AC 130 ms
54,036 KB
testcase_12 AC 128 ms
55,464 KB
testcase_13 AC 126 ms
55,756 KB
testcase_14 AC 125 ms
55,676 KB
testcase_15 AC 127 ms
55,964 KB
testcase_16 AC 127 ms
55,704 KB
testcase_17 AC 128 ms
56,008 KB
testcase_18 AC 130 ms
56,036 KB
testcase_19 AC 131 ms
55,520 KB
testcase_20 AC 125 ms
55,836 KB
testcase_21 AC 129 ms
55,612 KB
testcase_22 AC 124 ms
56,024 KB
testcase_23 AC 128 ms
55,804 KB
testcase_24 AC 128 ms
56,000 KB
testcase_25 AC 126 ms
55,740 KB
testcase_26 AC 127 ms
55,616 KB
testcase_27 AC 124 ms
55,948 KB
testcase_28 AC 125 ms
55,936 KB
testcase_29 AC 129 ms
55,948 KB
testcase_30 AC 126 ms
55,480 KB
testcase_31 AC 124 ms
55,656 KB
testcase_32 AC 129 ms
55,908 KB
testcase_33 AC 130 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no156;

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] c = new int[n];
		for(int i=0;i<n;i++) {
			c[i] = sc.nextInt();
		}
		Arrays.sort(c);
		int ans = 0;
		for(int i=0;i<n;i++) {
			int x = Math.min(m,c[i]);
			c[i] -= x;
			m -= x;
			if (c[i] == 0) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}
0