結果

問題 No.5 数字のブロック
ユーザー ちよちゃん
提出日時 2016-05-10 11:13:05
言語 Java
(openjdk 23)
結果
AC  
実行時間 245 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 3,666 ms
コンパイル使用メモリ 74,956 KB
実行使用メモリ 59,192 KB
最終ジャッジ日時 2024-11-18 08:35:58
合計ジャッジ時間 9,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Yuki1 {
	
	public static void main(String[] argas) {
	
		Scanner scan = new Scanner(System.in);
		// 箱の幅
		int box = scan.nextInt();
		// ブロックの数
		int blockCount = scan.nextInt();
	
		int[] blockWidth = new int [blockCount];
				
		for (int i = 0; i < blockWidth.length; i++) {
			blockWidth[i] = scan.nextInt();
		}
		
		Arrays.sort(blockWidth);
		
		int boxWidthAll = 0;
		int boxWidthAllCount = 0;
		
		for (int i = 0; i < blockWidth.length; i++) {

			boxWidthAll = boxWidthAll + blockWidth[i];
			
			if ( box < boxWidthAll) {
				break;
			}
			
			boxWidthAllCount++;
		}
		
		System.out.println(boxWidthAllCount);
	}	
}
0