結果

問題 No.156 キャンディー・ボックス
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 07:49:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 71,504 KB
実行使用メモリ 55,992 KB
最終ジャッジ日時 2023-09-19 03:17:24
合計ジャッジ時間 8,143 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,228 KB
testcase_01 AC 130 ms
55,380 KB
testcase_02 AC 129 ms
55,576 KB
testcase_03 AC 130 ms
55,384 KB
testcase_04 AC 130 ms
55,844 KB
testcase_05 AC 127 ms
55,268 KB
testcase_06 AC 128 ms
55,724 KB
testcase_07 AC 128 ms
55,992 KB
testcase_08 AC 129 ms
55,912 KB
testcase_09 AC 127 ms
55,376 KB
testcase_10 AC 128 ms
55,512 KB
testcase_11 AC 128 ms
55,384 KB
testcase_12 AC 127 ms
55,828 KB
testcase_13 AC 128 ms
55,532 KB
testcase_14 AC 129 ms
55,820 KB
testcase_15 AC 128 ms
55,868 KB
testcase_16 AC 127 ms
55,808 KB
testcase_17 AC 127 ms
55,240 KB
testcase_18 AC 127 ms
55,684 KB
testcase_19 AC 129 ms
55,532 KB
testcase_20 AC 128 ms
55,840 KB
testcase_21 AC 130 ms
55,252 KB
testcase_22 AC 128 ms
55,524 KB
testcase_23 AC 128 ms
55,696 KB
testcase_24 AC 126 ms
55,644 KB
testcase_25 AC 127 ms
55,728 KB
testcase_26 AC 126 ms
55,564 KB
testcase_27 AC 127 ms
55,524 KB
testcase_28 AC 128 ms
55,256 KB
testcase_29 AC 127 ms
55,700 KB
testcase_30 AC 131 ms
55,540 KB
testcase_31 AC 129 ms
55,400 KB
testcase_32 AC 129 ms
55,704 KB
testcase_33 AC 130 ms
55,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    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 count=0;
        for(int i=0; i<N; i++){
            M = M-C[i];
            if(M<0){
                break;
            }
            count++;
        }
        System.out.println(count);
    }
}
0