結果

問題 No.156 キャンディー・ボックス
ユーザー spaciaspacia
提出日時 2015-12-20 14:21:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 71,560 KB
実行使用メモリ 49,968 KB
最終ジャッジ日時 2023-09-19 03:04:07
合計ジャッジ時間 5,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
48,996 KB
testcase_01 AC 45 ms
49,204 KB
testcase_02 AC 44 ms
49,048 KB
testcase_03 AC 45 ms
48,800 KB
testcase_04 AC 45 ms
49,024 KB
testcase_05 AC 48 ms
49,200 KB
testcase_06 AC 45 ms
49,100 KB
testcase_07 AC 44 ms
49,148 KB
testcase_08 AC 44 ms
49,040 KB
testcase_09 AC 44 ms
49,304 KB
testcase_10 AC 45 ms
49,136 KB
testcase_11 AC 45 ms
47,404 KB
testcase_12 AC 45 ms
49,100 KB
testcase_13 AC 45 ms
49,244 KB
testcase_14 AC 44 ms
49,968 KB
testcase_15 AC 44 ms
49,608 KB
testcase_16 AC 45 ms
49,040 KB
testcase_17 AC 45 ms
49,004 KB
testcase_18 AC 45 ms
48,788 KB
testcase_19 AC 45 ms
49,172 KB
testcase_20 AC 45 ms
49,032 KB
testcase_21 AC 44 ms
49,120 KB
testcase_22 AC 44 ms
49,140 KB
testcase_23 AC 46 ms
49,392 KB
testcase_24 AC 45 ms
49,140 KB
testcase_25 AC 45 ms
49,072 KB
testcase_26 AC 45 ms
48,792 KB
testcase_27 AC 45 ms
49,324 KB
testcase_28 AC 45 ms
49,324 KB
testcase_29 AC 45 ms
49,176 KB
testcase_30 AC 45 ms
49,164 KB
testcase_31 AC 46 ms
49,188 KB
testcase_32 AC 45 ms
49,032 KB
testcase_33 AC 45 ms
49,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main156 {
	
	public static void out (Object out) {
		System.out.println(out);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String[] line1 = br.readLine().split(" ");
		String[] line2 = br.readLine().split(" ");
		
		int ans = 0, sum = 0;
		int n = Integer.parseInt(line1[0]);
		int m = Integer.parseInt(line1[1]);
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++)
			nums[i] = Integer.parseInt(line2[i]);
		
		Arrays.sort(nums);
		for (int i = 0; i < n; i++) {
			sum += nums[i];
			if (sum <= m) {
				ans++;
			} else {
				break;
			}
		}
		
		out(ans);
	}
}
0