結果

問題 No.156 キャンディー・ボックス
ユーザー 37zigen37zigen
提出日時 2016-03-31 18:01:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 568 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 72,560 KB
実行使用メモリ 59,044 KB
最終ジャッジ日時 2023-09-19 03:06:44
合計ジャッジ時間 11,021 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
55,332 KB
testcase_01 AC 130 ms
55,428 KB
testcase_02 AC 131 ms
55,492 KB
testcase_03 AC 133 ms
55,448 KB
testcase_04 AC 133 ms
55,444 KB
testcase_05 AC 211 ms
57,888 KB
testcase_06 AC 253 ms
57,876 KB
testcase_07 AC 234 ms
58,000 KB
testcase_08 AC 222 ms
57,492 KB
testcase_09 AC 212 ms
58,036 KB
testcase_10 AC 230 ms
58,124 KB
testcase_11 AC 208 ms
57,844 KB
testcase_12 AC 244 ms
58,332 KB
testcase_13 AC 226 ms
57,476 KB
testcase_14 AC 212 ms
58,024 KB
testcase_15 AC 228 ms
57,800 KB
testcase_16 AC 210 ms
57,704 KB
testcase_17 AC 223 ms
57,888 KB
testcase_18 AC 194 ms
57,720 KB
testcase_19 AC 199 ms
57,840 KB
testcase_20 AC 143 ms
55,300 KB
testcase_21 AC 179 ms
53,732 KB
testcase_22 AC 190 ms
58,000 KB
testcase_23 AC 179 ms
55,556 KB
testcase_24 AC 130 ms
55,164 KB
testcase_25 AC 129 ms
55,536 KB
testcase_26 AC 129 ms
55,708 KB
testcase_27 AC 127 ms
55,372 KB
testcase_28 AC 128 ms
55,552 KB
testcase_29 AC 132 ms
55,476 KB
testcase_30 AC 296 ms
56,904 KB
testcase_31 AC 266 ms
59,044 KB
testcase_32 AC 556 ms
58,748 KB
testcase_33 AC 568 ms
58,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder156;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		PriorityQueue<Integer> pq=new PriorityQueue<>();
		for(int i=0;i<n;i++){
			pq.add(sc.nextInt());
		}
		int count=0;
		for(int i=0;i<m;i++){
			int nnn=pq.poll();
			nnn--;
			if(nnn==0){
				count++;
				if(pq.isEmpty())break;
				continue;
			}
			pq.add(nnn);
			
		}
		System.out.println(count);
	}
}
0