結果

問題 No.156 キャンディー・ボックス
ユーザー kou6839kou6839
提出日時 2015-03-04 23:17:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 372 bytes
コンパイル時間 2,962 ms
コンパイル使用メモリ 71,768 KB
実行使用メモリ 56,856 KB
最終ジャッジ日時 2023-09-06 12:04:17
合計ジャッジ時間 9,140 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,004 KB
testcase_01 WA -
testcase_02 AC 113 ms
56,124 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 116 ms
56,460 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 119 ms
55,532 KB
testcase_19 AC 124 ms
55,832 KB
testcase_20 AC 122 ms
55,756 KB
testcase_21 AC 121 ms
55,808 KB
testcase_22 AC 122 ms
56,088 KB
testcase_23 AC 121 ms
55,596 KB
testcase_24 AC 120 ms
55,892 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 122 ms
55,564 KB
testcase_30 AC 124 ms
56,176 KB
testcase_31 AC 125 ms
56,184 KB
testcase_32 AC 125 ms
56,048 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] kya = new int[n];
		for(int i=0;i<n;i++){
			kya[i]=sc.nextInt();
		}
		Arrays.sort(kya);
		int ans=0;
		while(m>0&&ans<n){
			m-=Math.min(m, kya[ans]);
			ans++;
		}
		System.out.println(ans-1);
	}
}
0