結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー uafr_cs
提出日時 2015-09-07 01:49:16
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 813 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 82,936 KB
実行使用メモリ 78,452 KB
最終ジャッジ日時 2025-03-03 10:24:09
合計ジャッジ時間 14,703 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		long[] input = new long[N];
		for(int i = 0; i < N; i++){
			input[i] = sc.nextLong();
		}
		final long K = sc.nextLong();
		
		final double EPS = 1e-11;
		double upper = Arrays.stream(input).max().getAsLong();
		double lower = Double.MIN_VALUE;
		
		while((upper - lower) > EPS){
			final double middle = (upper + lower) / 2;
			
			long count = 0;
			for(int i = 0; i < N; i++){
				count += input[i] / middle;
			}
			
			if(count >= K){
				lower = middle;
			}else{
				upper = middle;
			}
		}
		
		System.out.printf("%.12f\n", lower);
	}

}
0