結果

問題 No.156 キャンディー・ボックス
ユーザー Mcpu3
提出日時 2018-06-22 00:17:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 2,919 ms
コンパイル使用メモリ 78,772 KB
実行使用メモリ 54,300 KB
最終ジャッジ日時 2024-07-05 16:20:30
合計ジャッジ時間 7,697 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class no156{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n,m,i,j,t,c[]=new int[10];
		n=stdIn.nextInt();
		m=stdIn.nextInt();
		for(i=0;i<n;i++) c[i]=stdIn.nextInt();
		for(i=0;i<n-1;i++) {
			for(j=n-1;j>i;j--) {
				if(c[j-1]>c[j]) {
					t=c[j-1];
					c[j-1]=c[j];
					c[j]=t;
				}
			}
		}
		for(i=0;m>0;i++) {
			while(c[i]>0&&m>0) {
				m--;
				c[i]--;
			}
		}
		if(c[i-1]>0) System.out.print(i-1);
		else System.out.print(i);
	}
}
0