結果

問題 No.5 数字のブロック
ユーザー kazapyon27
提出日時 2017-05-07 17:06:38
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 3,551 ms
コンパイル使用メモリ 75,216 KB
実行使用メモリ 58,604 KB
最終ジャッジ日時 2024-09-14 14:49:15
合計ジャッジ時間 11,392 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

/*No.5 数字のブロック*/
import java.util.*;
public class No5 {
	public static void main(String[] args) {
		short box_width,block_quantity,count;		
		try(Scanner input = new Scanner(System.in)){
			box_width=input.nextShort();
			block_quantity=input.nextShort();
			short block_width[]= new short[block_quantity];
			for(int i=0;i<block_quantity;i++){
				block_width[i]=input.nextShort();
			}
			Arrays.sort(block_width);
			for(count=1;count<=block_quantity;count++){
				box_width-=block_width[count-1];
				if(box_width==0){
					break;
				}else if(box_width<0){
					count-=1;
					break;
				}
			}
			System.out.println(count);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
0