結果

問題 No.156 キャンディー・ボックス
ユーザー GrenacheGrenache
提出日時 2015-09-23 21:59:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 6,699 ms
コンパイル使用メモリ 73,104 KB
実行使用メモリ 57,828 KB
最終ジャッジ日時 2023-09-19 03:00:42
合計ジャッジ時間 9,730 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,844 KB
testcase_01 AC 130 ms
55,836 KB
testcase_02 AC 128 ms
55,884 KB
testcase_03 AC 128 ms
55,896 KB
testcase_04 AC 130 ms
55,816 KB
testcase_05 AC 130 ms
55,852 KB
testcase_06 AC 131 ms
55,984 KB
testcase_07 AC 128 ms
55,728 KB
testcase_08 AC 128 ms
56,048 KB
testcase_09 AC 128 ms
55,588 KB
testcase_10 AC 129 ms
55,732 KB
testcase_11 AC 129 ms
55,976 KB
testcase_12 AC 129 ms
55,808 KB
testcase_13 AC 129 ms
56,052 KB
testcase_14 AC 130 ms
55,984 KB
testcase_15 AC 129 ms
56,248 KB
testcase_16 AC 130 ms
55,696 KB
testcase_17 AC 128 ms
55,792 KB
testcase_18 AC 129 ms
55,588 KB
testcase_19 AC 129 ms
55,868 KB
testcase_20 AC 129 ms
57,828 KB
testcase_21 AC 127 ms
56,364 KB
testcase_22 AC 129 ms
56,104 KB
testcase_23 AC 130 ms
56,068 KB
testcase_24 AC 130 ms
55,584 KB
testcase_25 AC 129 ms
55,992 KB
testcase_26 AC 129 ms
55,716 KB
testcase_27 AC 129 ms
55,932 KB
testcase_28 AC 128 ms
56,036 KB
testcase_29 AC 129 ms
55,904 KB
testcase_30 AC 128 ms
56,168 KB
testcase_31 AC 129 ms
56,024 KB
testcase_32 AC 128 ms
55,928 KB
testcase_33 AC 130 ms
55,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder156 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
        	c[i ]= sc.nextInt();
        }
        Arrays.sort(c);

        int i;
        for (i = 0; i < n; i++) {
        	if (m > c[i]) {
        		m -= c[i];
        	} else if (m == c[i]) {
        		i++;
        		break;
        	} else {
        		break;
        	}
        }

        System.out.println(i);
        
        sc.close();
    }
}
0