結果

問題 No.156 キャンディー・ボックス
ユーザー marumaru
提出日時 2016-03-23 15:44:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 3,673 ms
コンパイル使用メモリ 72,156 KB
実行使用メモリ 55,752 KB
最終ジャッジ日時 2023-09-19 03:06:27
合計ジャッジ時間 9,644 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,292 KB
testcase_01 AC 127 ms
55,588 KB
testcase_02 AC 128 ms
55,412 KB
testcase_03 AC 128 ms
55,440 KB
testcase_04 AC 130 ms
55,740 KB
testcase_05 AC 129 ms
55,448 KB
testcase_06 AC 128 ms
55,652 KB
testcase_07 AC 128 ms
55,296 KB
testcase_08 AC 131 ms
55,468 KB
testcase_09 AC 131 ms
55,600 KB
testcase_10 AC 129 ms
55,648 KB
testcase_11 AC 129 ms
55,444 KB
testcase_12 AC 127 ms
53,648 KB
testcase_13 AC 129 ms
55,584 KB
testcase_14 AC 131 ms
55,560 KB
testcase_15 AC 131 ms
55,188 KB
testcase_16 AC 130 ms
55,752 KB
testcase_17 AC 127 ms
55,444 KB
testcase_18 AC 130 ms
55,164 KB
testcase_19 AC 129 ms
55,284 KB
testcase_20 AC 127 ms
55,596 KB
testcase_21 AC 129 ms
55,292 KB
testcase_22 AC 129 ms
55,632 KB
testcase_23 AC 131 ms
55,464 KB
testcase_24 AC 130 ms
55,416 KB
testcase_25 AC 130 ms
55,704 KB
testcase_26 AC 130 ms
55,448 KB
testcase_27 AC 129 ms
55,612 KB
testcase_28 AC 129 ms
55,164 KB
testcase_29 AC 129 ms
55,564 KB
testcase_30 AC 130 ms
55,592 KB
testcase_31 AC 130 ms
55,480 KB
testcase_32 AC 130 ms
55,448 KB
testcase_33 AC 129 ms
55,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class yukicoder_156 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		
		int[] box = new int[n];
		
		for (int i = 0; i < n; i++) {
			box[i] = stdIn.nextInt();
		}
		
		for (int i = 1; i <= box.length; i++) {
	        for (int j = 0; j < box.length - 1; j++) {
	        	if (box[j] > box[j+1]) {
	            	int t;
	                t = box[j];
	                box[j] = box[j+1];
	                box[j+1] = t;
	            }
	        }
		}
		
		int candy = 0, i = 0;
		
		for(i = 0; i < box.length; i++) {
			candy += box[i];
			if (candy > m) {
				break;
			}
		}
		
		System.out.println(i);
	}
}
0