結果

問題 No.5 数字のブロック
ユーザー ottfoekst
提出日時 2015-02-01 03:08:14
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,025 bytes
コンパイル時間 3,135 ms
コンパイル使用メモリ 74,900 KB
実行使用メモリ 52,852 KB
最終ジャッジ日時 2024-06-23 04:45:38
合計ジャッジ時間 6,384 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 7 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No5 {
	
	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		
		int boxLength;
		
		// inputの準備
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boxLength = Integer.parseInt(br.readLine());
		br.readLine();
		String[] blockLengthStringList = br.readLine().split(" ");
		int[] blockLengthList = new int[blockLengthStringList.length];
		for(int i=0; i < blockLengthStringList.length; i++) {
			blockLengthList[i] = Integer.parseInt(blockLengthStringList[i]);
		}
		Arrays.sort(blockLengthList);
		
		// ボックスに最大何個入れられるかを計算
		int insertNum = -1;
		int sumLength = 0;
		for(int i = 0; sumLength < boxLength; i++) {
			sumLength += blockLengthList[i];
			insertNum++;
		}
		System.out.println(insertNum);
	}
}
0