結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー uafr_csuafr_cs
提出日時 2015-09-07 02:10:53
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,886 bytes
コンパイル時間 4,668 ms
コンパイル使用メモリ 77,916 KB
実行使用メモリ 71,720 KB
最終ジャッジ日時 2023-09-26 09:56:57
合計ジャッジ時間 17,754 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 402 ms
71,720 KB
testcase_01 AC 118 ms
55,744 KB
testcase_02 AC 339 ms
60,940 KB
testcase_03 AC 477 ms
67,080 KB
testcase_04 AC 546 ms
69,000 KB
testcase_05 AC 510 ms
65,012 KB
testcase_06 AC 506 ms
64,680 KB
testcase_07 AC 562 ms
70,924 KB
testcase_08 AC 556 ms
71,212 KB
testcase_09 AC 523 ms
67,316 KB
testcase_10 AC 493 ms
62,840 KB
testcase_11 AC 499 ms
65,684 KB
testcase_12 AC 514 ms
67,044 KB
testcase_13 AC 543 ms
71,280 KB
testcase_14 AC 515 ms
66,876 KB
testcase_15 AC 518 ms
66,440 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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-9;
		double upper = Arrays.stream(input).max().getAsLong();
		double lower = (double)(Arrays.stream(input).min().getAsLong()) / K;
		
		while(upper - EPS > lower){
			final double middle = upper / 2 + lower / 2;
			//System.out.printf("%.12f %.12f %.12f \n", 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;
			}
		}
		
		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();
		}
	}

}
0