結果

問題 No.156 キャンディー・ボックス
ユーザー YOSHIYOSHI
提出日時 2021-03-02 20:08:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 4,483 ms
コンパイル使用メモリ 80,244 KB
実行使用メモリ 53,132 KB
最終ジャッジ日時 2024-04-14 04:51:34
合計ジャッジ時間 7,422 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
51,284 KB
testcase_01 AC 66 ms
51,148 KB
testcase_02 AC 66 ms
50,816 KB
testcase_03 AC 66 ms
51,088 KB
testcase_04 AC 67 ms
51,336 KB
testcase_05 AC 66 ms
51,304 KB
testcase_06 AC 67 ms
51,040 KB
testcase_07 AC 66 ms
51,276 KB
testcase_08 AC 66 ms
51,084 KB
testcase_09 AC 66 ms
51,184 KB
testcase_10 AC 66 ms
51,196 KB
testcase_11 AC 66 ms
51,296 KB
testcase_12 AC 65 ms
50,696 KB
testcase_13 AC 66 ms
50,912 KB
testcase_14 AC 67 ms
50,828 KB
testcase_15 AC 67 ms
51,060 KB
testcase_16 AC 67 ms
51,120 KB
testcase_17 AC 68 ms
51,212 KB
testcase_18 AC 66 ms
51,304 KB
testcase_19 AC 66 ms
53,132 KB
testcase_20 AC 66 ms
51,216 KB
testcase_21 AC 68 ms
51,172 KB
testcase_22 AC 67 ms
51,068 KB
testcase_23 AC 67 ms
50,936 KB
testcase_24 AC 67 ms
50,864 KB
testcase_25 AC 66 ms
50,968 KB
testcase_26 AC 66 ms
51,160 KB
testcase_27 AC 67 ms
51,328 KB
testcase_28 AC 67 ms
51,256 KB
testcase_29 AC 69 ms
51,144 KB
testcase_30 AC 67 ms
51,132 KB
testcase_31 AC 67 ms
50,944 KB
testcase_32 AC 66 ms
50,928 KB
testcase_33 AC 68 ms
51,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class No00000156_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] mArr = br.readLine().split(" ");
		int n = Integer.parseInt(mArr[0]);
		int m = Integer.parseInt(mArr[1]);
		int[] cArr = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		Arrays.sort(cArr);;
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(m >= cArr[i]) {
				cnt++;
				m -= cArr[i];
			}
		}
		System.out.println(cnt);
	}
}
0