結果

問題 No.156 キャンディー・ボックス
ユーザー kou6839kou6839
提出日時 2015-03-04 23:23:33
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 374 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 72,948 KB
実行使用メモリ 57,968 KB
最終ジャッジ日時 2023-09-06 12:56:56
合計ジャッジ時間 7,783 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,040 KB
testcase_01 AC 121 ms
55,824 KB
testcase_02 AC 120 ms
54,316 KB
testcase_03 AC 121 ms
55,748 KB
testcase_04 AC 121 ms
56,008 KB
testcase_05 AC 121 ms
56,132 KB
testcase_06 AC 122 ms
56,084 KB
testcase_07 AC 124 ms
55,620 KB
testcase_08 AC 122 ms
55,968 KB
testcase_09 AC 122 ms
56,296 KB
testcase_10 AC 121 ms
55,832 KB
testcase_11 AC 121 ms
55,956 KB
testcase_12 AC 122 ms
55,828 KB
testcase_13 AC 121 ms
55,964 KB
testcase_14 AC 123 ms
55,836 KB
testcase_15 AC 123 ms
55,960 KB
testcase_16 AC 122 ms
56,004 KB
testcase_17 AC 122 ms
55,716 KB
testcase_18 AC 122 ms
56,120 KB
testcase_19 AC 124 ms
56,180 KB
testcase_20 AC 120 ms
55,728 KB
testcase_21 AC 125 ms
55,708 KB
testcase_22 AC 122 ms
55,992 KB
testcase_23 AC 121 ms
56,256 KB
testcase_24 RE -
testcase_25 AC 120 ms
55,480 KB
testcase_26 AC 121 ms
55,720 KB
testcase_27 AC 123 ms
53,952 KB
testcase_28 AC 122 ms
56,052 KB
testcase_29 RE -
testcase_30 AC 123 ms
55,920 KB
testcase_31 AC 120 ms
55,900 KB
testcase_32 AC 122 ms
56,292 KB
testcase_33 AC 122 ms
55,712 KB
権限があれば一括ダウンロードができます

ソースコード

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){
			if(m>=kya[ans])ans++;
			m-=kya[ans-1];
		}
		System.out.println(ans);
	}
}
0