結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー moecocoa
提出日時 2018-03-28 09:51:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,036 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 76,376 KB
実行使用メモリ 70,388 KB
最終ジャッジ日時 2025-03-03 11:10:31
合計ジャッジ時間 29,133 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main{
	static int N;
	static int[] l;
	static long K;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		l = new int[N];
		for(int i=0; i<N; i++){
			l[i] = sc.nextInt();
		}
		K = sc.nextLong();
            
		double lb = 0, ub = 1e12;
		for(int cnt = 0; cnt < 100; cnt++) { // while (ub - lb > 1)
			double mid = (lb + ub) / 2;

			long sum = 0;
			for(int i=0; i<N; i++){
				sum += l[i] / mid;
			}

			if (sum >= K) lb = mid;
			else ub = mid;
		}

		System.out.println(lb);
	}
}
0