結果

問題 No.5 数字のブロック
ユーザー ちよちゃん
提出日時 2016-05-09 21:43:34
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 835 bytes
コンパイル時間 3,553 ms
コンパイル使用メモリ 75,024 KB
実行使用メモリ 41,704 KB
最終ジャッジ日時 2024-10-05 13:14:42
合計ジャッジ時間 9,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 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 box = 16;
		// ブロックの数
		int blockCount = scan.nextInt();
		//int blockCount = 3;
		int num = scan.nextInt();
		int blockWidth[] = new int [num];
		//int blockWidth[] = {10,5,7};
		/*
		for (int i = 0; i <= num; i++) {
			blockWidth[i] = scan.nextInt();
		}*/
		
		Arrays.sort(blockWidth);
		/*
		for(int i = 0; i< 3; i++){
			System.out.println(blockWidth[i]);
		}
		*/
		
		int boxWidthAll = 0;
		int boxWidthAllCount = 0;
		
		while(box>boxWidthAll){
			
			boxWidthAll +=blockWidth[boxWidthAllCount];

			if(box>boxWidthAll) {
				boxWidthAllCount++;
			}
		}
		
		System.out.println(boxWidthAllCount);
	}	
}
0