結果

問題 No.5 数字のブロック
ユーザー kazapyon27
提出日時 2017-05-07 17:21:41
言語 Java
(openjdk 23)
結果
AC  
実行時間 260 ms / 5,000 ms
コード長 646 bytes
コンパイル時間 3,211 ms
コンパイル使用メモリ 75,408 KB
実行使用メモリ 58,548 KB
最終ジャッジ日時 2024-11-18 11:02:46
合計ジャッジ時間 10,547 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

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;
				}
			}
			System.out.println(count-1);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
0