結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー scache
提出日時 2015-06-08 12:07:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,108 ms / 5,000 ms
コード長 898 bytes
コンパイル時間 3,328 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 72,160 KB
最終ジャッジ日時 2025-03-03 10:19:37
合計ジャッジ時間 30,247 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.text.NumberFormat;
import java.util.Scanner;

public class Main0145 {

	public static void main(String[] args) {
		new Main0145();
	}

	public Main0145() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] l = new long[N];
		for(int i=0;i<N;i++)
			l[i] = sc.nextLong();
		long K = sc.nextLong();
		solve(N, l, K);
	}

	private void solve(int n, long[] l, long k) {
		double res = 0;
		double low = 0;
		double high = Integer.MAX_VALUE;
		
		for(int i=0;i<200;i++){
			long count = 0;
			double mid = (high+low)/2;
			
			for(long s: l){
				count += s/mid;
			}
//			System.out.println(count + " " + mid);
			if(count>=k){
				low = mid;
				res = mid;
			}else{
				high = mid;
			}
		}
		NumberFormat format = NumberFormat.getInstance();
		format.setGroupingUsed(false);
		format.setMaximumFractionDigits(11);
		
		System.out.println(format.format(res));
	}
}
0