結果

問題 No.156 キャンディー・ボックス
ユーザー リチウムリチウム
提出日時 2015-02-26 23:42:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 4,358 ms
コンパイル使用メモリ 72,052 KB
実行使用メモリ 56,092 KB
最終ジャッジ日時 2023-09-18 18:44:06
合計ジャッジ時間 10,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
56,028 KB
testcase_01 AC 126 ms
55,860 KB
testcase_02 AC 125 ms
55,696 KB
testcase_03 AC 126 ms
55,808 KB
testcase_04 AC 126 ms
55,708 KB
testcase_05 AC 147 ms
55,748 KB
testcase_06 AC 159 ms
55,956 KB
testcase_07 AC 150 ms
55,664 KB
testcase_08 AC 149 ms
55,936 KB
testcase_09 AC 149 ms
55,816 KB
testcase_10 AC 152 ms
56,036 KB
testcase_11 AC 147 ms
55,848 KB
testcase_12 AC 156 ms
55,640 KB
testcase_13 AC 147 ms
55,888 KB
testcase_14 AC 148 ms
55,764 KB
testcase_15 AC 151 ms
55,584 KB
testcase_16 AC 149 ms
55,820 KB
testcase_17 AC 150 ms
55,992 KB
testcase_18 AC 147 ms
55,800 KB
testcase_19 AC 150 ms
56,092 KB
testcase_20 AC 134 ms
55,624 KB
testcase_21 AC 141 ms
56,020 KB
testcase_22 AC 145 ms
55,508 KB
testcase_23 AC 143 ms
55,376 KB
testcase_24 AC 125 ms
55,900 KB
testcase_25 AC 125 ms
55,572 KB
testcase_26 AC 125 ms
56,084 KB
testcase_27 AC 125 ms
55,860 KB
testcase_28 AC 126 ms
55,836 KB
testcase_29 AC 126 ms
55,624 KB
testcase_30 AC 172 ms
56,040 KB
testcase_31 AC 152 ms
55,984 KB
testcase_32 AC 334 ms
55,596 KB
testcase_33 AC 331 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class yukicoder {
	
	
	public static void main(String args[]) {
			Scanner sc=new Scanner(System.in);
			int n=sc.nextInt();
			int m=sc.nextInt();
			int box[]=new int[n];
			for(int i=0;i<n;i++){
				box[i]=sc.nextInt();
			}
			int ans=0;
			while(m>0){
				Arrays.sort(box);
				for(int i=0;i<n;i++){
					if(box[i]>0){
						box[i]--;
						m--;
						break;
					}
				}
			}
			Arrays.sort(box);
			for(int i=0;i<n;i++){
				if(box[i]==0)ans++;
			}
			System.out.println(ans);
			
	}

}


			
0