結果

問題 No.156 キャンディー・ボックス
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-15 19:44:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 3,556 ms
コンパイル使用メモリ 72,064 KB
実行使用メモリ 56,112 KB
最終ジャッジ日時 2023-09-19 03:35:27
合計ジャッジ時間 9,259 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,196 KB
testcase_01 AC 128 ms
55,204 KB
testcase_02 AC 129 ms
55,564 KB
testcase_03 AC 127 ms
55,780 KB
testcase_04 AC 127 ms
55,868 KB
testcase_05 AC 129 ms
55,912 KB
testcase_06 AC 128 ms
55,488 KB
testcase_07 AC 130 ms
56,112 KB
testcase_08 AC 131 ms
55,616 KB
testcase_09 AC 130 ms
55,848 KB
testcase_10 AC 128 ms
55,848 KB
testcase_11 AC 128 ms
55,636 KB
testcase_12 AC 129 ms
55,772 KB
testcase_13 AC 130 ms
55,596 KB
testcase_14 AC 127 ms
55,184 KB
testcase_15 AC 129 ms
55,344 KB
testcase_16 AC 130 ms
55,628 KB
testcase_17 AC 135 ms
55,488 KB
testcase_18 AC 128 ms
55,824 KB
testcase_19 AC 130 ms
55,572 KB
testcase_20 AC 129 ms
55,840 KB
testcase_21 AC 128 ms
55,472 KB
testcase_22 AC 128 ms
55,308 KB
testcase_23 AC 127 ms
55,784 KB
testcase_24 AC 128 ms
55,548 KB
testcase_25 AC 128 ms
55,264 KB
testcase_26 AC 126 ms
55,296 KB
testcase_27 AC 128 ms
55,508 KB
testcase_28 AC 127 ms
55,428 KB
testcase_29 AC 128 ms
55,696 KB
testcase_30 AC 129 ms
55,656 KB
testcase_31 AC 130 ms
55,576 KB
testcase_32 AC 128 ms
55,624 KB
testcase_33 AC 128 ms
55,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class No156 {
	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 sum = 0;
		int x = 0;
		while(true) {
			sum += C[x];
			if(sum >= M) {
				if(sum == M) {
					x++;
				}
				break;
			}
			x++;
		}
		
		System.out.println(x);
	}
}
0