結果
| 問題 | No.67 よくある棒を切る問題 (1) | 
| コンテスト | |
| ユーザー |  uafr_cs | 
| 提出日時 | 2015-09-07 02:15:00 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,851 ms / 5,000 ms | 
| コード長 | 1,944 bytes | 
| コンパイル時間 | 2,319 ms | 
| コンパイル使用メモリ | 82,192 KB | 
| 実行使用メモリ | 72,832 KB | 
| 最終ジャッジ日時 | 2025-03-03 10:25:16 | 
| 合計ジャッジ時間 | 26,148 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
ソースコード
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) throws IOException {
		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-10;
		double upper = Arrays.stream(input).max().getAsLong();
		double lower = (double)(Arrays.stream(input).min().getAsLong()) / K;
		
		int loops = 0;
		while(upper > lower + EPS && loops < 1000){
			final double middle = upper / 2 + lower / 2;
			//System.out.printf("%.12f %.12f %.12f \n", upper, upper - lower, middle);
			
			long count = 0;
			for(int i = 0; i < N; i++){
				count += input[i] / middle;
			}
			
			if(count >= K){
				lower = middle;
			}else{
				upper = middle;
			}
			
			loops++;
		}
		
		System.out.printf("%.12f\n", lower);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}
            
            
            
        