結果

問題 No.5 数字のブロック
コンテスト
ユーザー ottfoekst
提出日時 2015-02-01 03:08:14
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 1,025 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,805 ms
コンパイル使用メモリ 82,984 KB
実行使用メモリ 46,136 KB
最終ジャッジ日時 2026-03-07 19:23:40
合計ジャッジ時間 5,249 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 7 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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