結果

問題 No.156 キャンディー・ボックス
ユーザー jimanojimano
提出日時 2018-01-18 23:31:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 3,809 ms
コンパイル使用メモリ 72,160 KB
実行使用メモリ 49,808 KB
最終ジャッジ日時 2023-09-19 03:34:31
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,372 KB
testcase_01 AC 45 ms
49,160 KB
testcase_02 AC 46 ms
49,660 KB
testcase_03 AC 45 ms
49,408 KB
testcase_04 AC 46 ms
49,168 KB
testcase_05 AC 47 ms
49,356 KB
testcase_06 AC 48 ms
49,172 KB
testcase_07 AC 45 ms
49,344 KB
testcase_08 AC 46 ms
49,468 KB
testcase_09 AC 44 ms
49,380 KB
testcase_10 AC 46 ms
49,404 KB
testcase_11 AC 46 ms
49,272 KB
testcase_12 AC 46 ms
49,316 KB
testcase_13 AC 46 ms
49,336 KB
testcase_14 AC 45 ms
49,808 KB
testcase_15 AC 47 ms
49,412 KB
testcase_16 AC 46 ms
49,336 KB
testcase_17 AC 46 ms
49,464 KB
testcase_18 AC 46 ms
49,164 KB
testcase_19 AC 45 ms
49,192 KB
testcase_20 AC 46 ms
49,456 KB
testcase_21 AC 46 ms
49,404 KB
testcase_22 AC 46 ms
49,460 KB
testcase_23 AC 45 ms
47,708 KB
testcase_24 AC 46 ms
49,720 KB
testcase_25 AC 44 ms
49,188 KB
testcase_26 AC 44 ms
49,492 KB
testcase_27 AC 45 ms
49,296 KB
testcase_28 AC 46 ms
49,348 KB
testcase_29 AC 45 ms
49,352 KB
testcase_30 AC 45 ms
49,352 KB
testcase_31 AC 45 ms
49,316 KB
testcase_32 AC 46 ms
49,372 KB
testcase_33 AC 46 ms
49,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No0156 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] s1 = br.readLine().split(" ");
			String[] s2 = br.readLine().split(" ");
			int N = Integer.parseInt(s1[0]);
			int M = Integer.parseInt(s1[1]);			
			int[] candy = new int[N];
			int cntBox = 0;

			for (int i = 0; i < N; i++) {
				candy[i] = Integer.parseInt(s2[i]);
			}
			Arrays.sort(candy);
			for (int i = 0; i < N; i++) {
				M -= candy[i];
				if(M < 0) {
					break;
				}
				cntBox++;
			}
			System.out.println(cntBox);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
0