結果

問題 No.156 キャンディー・ボックス
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 21:58:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 71,972 KB
実行使用メモリ 56,304 KB
最終ジャッジ日時 2023-09-18 19:33:21
合計ジャッジ時間 8,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,848 KB
testcase_01 AC 127 ms
56,136 KB
testcase_02 AC 128 ms
55,932 KB
testcase_03 AC 129 ms
56,204 KB
testcase_04 AC 128 ms
55,428 KB
testcase_05 AC 127 ms
55,488 KB
testcase_06 AC 130 ms
56,304 KB
testcase_07 AC 128 ms
55,892 KB
testcase_08 AC 130 ms
55,988 KB
testcase_09 AC 127 ms
55,932 KB
testcase_10 AC 128 ms
55,916 KB
testcase_11 AC 129 ms
55,596 KB
testcase_12 AC 128 ms
56,156 KB
testcase_13 AC 129 ms
55,784 KB
testcase_14 AC 129 ms
55,668 KB
testcase_15 AC 128 ms
56,032 KB
testcase_16 AC 128 ms
55,668 KB
testcase_17 AC 129 ms
55,928 KB
testcase_18 AC 130 ms
55,732 KB
testcase_19 AC 133 ms
55,660 KB
testcase_20 AC 128 ms
56,240 KB
testcase_21 AC 127 ms
55,556 KB
testcase_22 AC 128 ms
55,784 KB
testcase_23 AC 127 ms
55,564 KB
testcase_24 AC 126 ms
55,496 KB
testcase_25 AC 127 ms
55,904 KB
testcase_26 AC 126 ms
55,736 KB
testcase_27 AC 124 ms
55,824 KB
testcase_28 AC 126 ms
56,124 KB
testcase_29 AC 127 ms
56,128 KB
testcase_30 AC 128 ms
55,560 KB
testcase_31 AC 129 ms
55,932 KB
testcase_32 AC 129 ms
55,768 KB
testcase_33 AC 129 ms
56,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
       int n = koko.nextInt();
       int m = koko.nextInt();
       int[] c = new int[n];
       for(int i = 0; i<n; i++){
           c[i] = koko.nextInt();
       }
       Arrays.sort(c);
       int emp = 0;
       int pick = 0;
       for(int i = 0; i<n; i++){
           pick = pick + c[i];
           if(pick<=m){
               emp = emp + 1;
           }else{
               break;
           }
       }
       System.out.println(emp);
    }
}
0