結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー moetomatomoetomato
提出日時 2018-02-06 14:45:44
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 630 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 71,176 KB
実行使用メモリ 67,128 KB
最終ジャッジ日時 2023-09-25 07:20:23
合計ジャッジ時間 25,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 944 ms
64,712 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 889 ms
65,024 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 937 ms
64,688 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 841 ms
64,680 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 918 ms
64,572 KB
testcase_16 AC 940 ms
64,800 KB
testcase_17 AC 942 ms
65,204 KB
testcase_18 AC 880 ms
64,532 KB
testcase_19 AC 931 ms
64,716 KB
testcase_20 AC 914 ms
64,688 KB
testcase_21 AC 958 ms
65,172 KB
testcase_22 AC 822 ms
64,768 KB
testcase_23 AC 838 ms
64,432 KB
testcase_24 AC 122 ms
55,880 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 190 ms
56,072 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	static int N;
	static int[] l;
	static int 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.nextInt();

		double lb = 0, ub = 1e12;
		for(int cnt = 0; cnt < 100; cnt++) { // while (ub - lb > 1)
			double mid = (lb + ub) / 2;

			if (mid < 1e-10) {
				lb = mid;
				continue;
			}

			int 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