結果

問題 No.156 キャンディー・ボックス
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 14:25:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 2,803 ms
コンパイル使用メモリ 71,688 KB
実行使用メモリ 56,220 KB
最終ジャッジ日時 2023-09-19 03:35:17
合計ジャッジ時間 8,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,032 KB
testcase_01 AC 128 ms
55,492 KB
testcase_02 AC 130 ms
55,464 KB
testcase_03 AC 128 ms
56,000 KB
testcase_04 AC 125 ms
55,740 KB
testcase_05 AC 125 ms
55,732 KB
testcase_06 AC 129 ms
55,692 KB
testcase_07 AC 125 ms
55,796 KB
testcase_08 AC 128 ms
55,792 KB
testcase_09 AC 130 ms
55,808 KB
testcase_10 AC 131 ms
56,032 KB
testcase_11 AC 128 ms
55,808 KB
testcase_12 AC 129 ms
55,656 KB
testcase_13 AC 127 ms
55,684 KB
testcase_14 AC 126 ms
55,808 KB
testcase_15 AC 127 ms
55,908 KB
testcase_16 AC 127 ms
56,072 KB
testcase_17 AC 128 ms
55,520 KB
testcase_18 AC 128 ms
56,220 KB
testcase_19 AC 128 ms
55,764 KB
testcase_20 AC 132 ms
55,724 KB
testcase_21 AC 126 ms
56,016 KB
testcase_22 AC 126 ms
55,692 KB
testcase_23 AC 130 ms
55,884 KB
testcase_24 AC 127 ms
55,644 KB
testcase_25 AC 128 ms
56,160 KB
testcase_26 AC 129 ms
55,900 KB
testcase_27 AC 128 ms
55,984 KB
testcase_28 AC 127 ms
55,808 KB
testcase_29 AC 129 ms
55,856 KB
testcase_30 AC 131 ms
55,980 KB
testcase_31 AC 127 ms
55,496 KB
testcase_32 AC 131 ms
55,848 KB
testcase_33 AC 131 ms
55,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] ar = new long[n];
		int num = 0;
		for (int i=0; i<n; i++) {
			ar[i] = sc.nextInt();
		}
		Arrays.sort(ar);
		for (int i=0; i<n; i++) {
			if (i!=0) {
				ar[i] = ar[i] + ar[i-1];
			}
			if (ar[i] <= m) {num++;}
		}
		System.out.println(num);
	}
}
0