結果

問題 No.156 キャンディー・ボックス
ユーザー ちよちゃんちよちゃん
提出日時 2016-06-04 13:49:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 3,443 ms
コンパイル使用メモリ 72,780 KB
実行使用メモリ 57,692 KB
最終ジャッジ日時 2023-09-19 03:11:07
合計ジャッジ時間 9,332 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,712 KB
testcase_01 AC 129 ms
55,776 KB
testcase_02 AC 129 ms
56,060 KB
testcase_03 AC 128 ms
55,488 KB
testcase_04 AC 128 ms
55,844 KB
testcase_05 AC 128 ms
55,576 KB
testcase_06 AC 130 ms
55,744 KB
testcase_07 AC 127 ms
55,840 KB
testcase_08 AC 129 ms
55,716 KB
testcase_09 AC 131 ms
55,908 KB
testcase_10 AC 128 ms
55,756 KB
testcase_11 AC 128 ms
53,784 KB
testcase_12 AC 127 ms
55,808 KB
testcase_13 AC 127 ms
55,884 KB
testcase_14 AC 129 ms
57,692 KB
testcase_15 AC 126 ms
55,984 KB
testcase_16 AC 128 ms
55,604 KB
testcase_17 AC 128 ms
56,012 KB
testcase_18 AC 128 ms
55,740 KB
testcase_19 AC 128 ms
55,812 KB
testcase_20 AC 127 ms
55,936 KB
testcase_21 AC 127 ms
55,888 KB
testcase_22 AC 128 ms
55,808 KB
testcase_23 AC 126 ms
55,524 KB
testcase_24 AC 126 ms
56,052 KB
testcase_25 AC 126 ms
55,684 KB
testcase_26 AC 131 ms
55,828 KB
testcase_27 AC 127 ms
55,420 KB
testcase_28 AC 128 ms
55,724 KB
testcase_29 AC 128 ms
56,096 KB
testcase_30 AC 130 ms
55,648 KB
testcase_31 AC 128 ms
55,908 KB
testcase_32 AC 131 ms
55,360 KB
testcase_33 AC 129 ms
55,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

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

public class Yuki156 {
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int candyBox[] = new int[n];
		
		for (int i = 0; i < n; i++) {
			candyBox[i] = scan.nextInt();
		}
		
		Arrays.sort(candyBox);
		
		scan.close();
		
		int boxCount = 0;
		for (int i = 0; i < n; i++) {
			m -=candyBox[i];
			if (m >= 0) {
				boxCount++;
			}
		}
		System.out.println(boxCount);
	}
	
}
0