結果

問題 No.156 キャンディー・ボックス
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-24 01:52:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 3,386 ms
コンパイル使用メモリ 72,784 KB
実行使用メモリ 49,692 KB
最終ジャッジ日時 2023-09-19 03:28:50
合計ジャッジ時間 6,413 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,312 KB
testcase_01 AC 45 ms
49,244 KB
testcase_02 AC 45 ms
49,252 KB
testcase_03 AC 45 ms
49,360 KB
testcase_04 AC 45 ms
49,312 KB
testcase_05 AC 45 ms
49,352 KB
testcase_06 AC 46 ms
49,476 KB
testcase_07 AC 46 ms
49,268 KB
testcase_08 AC 46 ms
49,364 KB
testcase_09 AC 45 ms
49,096 KB
testcase_10 AC 47 ms
49,544 KB
testcase_11 AC 44 ms
49,164 KB
testcase_12 AC 45 ms
49,584 KB
testcase_13 AC 44 ms
49,472 KB
testcase_14 AC 45 ms
49,396 KB
testcase_15 AC 45 ms
49,412 KB
testcase_16 AC 44 ms
49,460 KB
testcase_17 AC 46 ms
49,300 KB
testcase_18 AC 46 ms
49,064 KB
testcase_19 AC 47 ms
49,620 KB
testcase_20 AC 47 ms
49,300 KB
testcase_21 AC 45 ms
49,376 KB
testcase_22 AC 46 ms
49,248 KB
testcase_23 AC 47 ms
49,624 KB
testcase_24 AC 46 ms
49,108 KB
testcase_25 AC 45 ms
49,692 KB
testcase_26 AC 46 ms
49,236 KB
testcase_27 AC 46 ms
49,244 KB
testcase_28 AC 46 ms
49,200 KB
testcase_29 AC 46 ms
49,468 KB
testcase_30 AC 45 ms
49,556 KB
testcase_31 AC 45 ms
49,360 KB
testcase_32 AC 46 ms
49,244 KB
testcase_33 AC 46 ms
49,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No156 {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str1 = br.readLine().split(" ");
		String[] str2 = br.readLine().split(" ");
		int N = Integer.parseInt(str1[0]);
		int M = Integer.parseInt(str1[1]);
		int[] C = new int[N];
		for(int i=0; i < N; i++) C[i] = Integer.parseInt(str2[i]);
		Arrays.sort(C);
		getAns(M, C);
	}
	
	public static void getAns(int a, int[] b){
		int ans = 0;
		for(int i=0; i< b.length; i++){
			a -= b[i];
			ans++;
			if(a < 0) {
				ans--;
				break;
			}
		}
		System.out.println(ans);
	}
}
0