結果

問題 No.156 キャンディー・ボックス
ユーザー rf141rf141
提出日時 2015-08-10 02:33:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 3,292 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 56,348 KB
最終ジャッジ日時 2023-09-18 19:40:03
合計ジャッジ時間 9,312 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,788 KB
testcase_01 AC 129 ms
55,616 KB
testcase_02 AC 126 ms
55,600 KB
testcase_03 AC 127 ms
55,592 KB
testcase_04 AC 127 ms
55,912 KB
testcase_05 AC 136 ms
56,112 KB
testcase_06 AC 137 ms
56,016 KB
testcase_07 AC 136 ms
55,852 KB
testcase_08 AC 139 ms
55,892 KB
testcase_09 AC 136 ms
55,880 KB
testcase_10 AC 135 ms
55,920 KB
testcase_11 AC 134 ms
55,576 KB
testcase_12 AC 134 ms
55,960 KB
testcase_13 AC 139 ms
55,912 KB
testcase_14 AC 134 ms
55,924 KB
testcase_15 AC 135 ms
55,844 KB
testcase_16 AC 136 ms
55,892 KB
testcase_17 AC 135 ms
55,764 KB
testcase_18 AC 136 ms
55,908 KB
testcase_19 AC 135 ms
55,592 KB
testcase_20 AC 127 ms
55,716 KB
testcase_21 AC 129 ms
55,740 KB
testcase_22 AC 135 ms
55,580 KB
testcase_23 AC 130 ms
56,348 KB
testcase_24 AC 126 ms
55,996 KB
testcase_25 AC 127 ms
55,628 KB
testcase_26 AC 127 ms
55,936 KB
testcase_27 AC 127 ms
56,064 KB
testcase_28 AC 127 ms
55,904 KB
testcase_29 AC 127 ms
56,136 KB
testcase_30 AC 136 ms
55,912 KB
testcase_31 AC 141 ms
55,992 KB
testcase_32 AC 148 ms
55,892 KB
testcase_33 AC 147 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class candy{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		System.out.println(docandy(n,m,scan));
	}
	public static int docandy(int n,int m,Scanner scan){
		int[] candyBox = new int[n];
		for(int i = 0; i < n; i++){
			candyBox[i] = scan.nextInt();
		}
		Arrays.sort(candyBox);
		int count=0,now=0;
		while(count<m && now < n){
			if(candyBox[now]!=0){
				count++;
				candyBox[now]-=1;	
			}
			if(candyBox[now]==0){
				now++;
			}
		}
		return now;
	}
}
0