結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-21 23:44:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 631 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 87,644 KB
実行使用メモリ 111,732 KB
最終ジャッジ日時 2023-09-22 21:07:28
合計ジャッジ時間 7,294 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
101,828 KB
testcase_01 WA -
testcase_02 AC 118 ms
88,268 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 223 ms
108,340 KB
testcase_07 AC 192 ms
101,104 KB
testcase_08 WA -
testcase_09 AC 229 ms
100,908 KB
testcase_10 AC 174 ms
104,172 KB
testcase_11 AC 178 ms
107,508 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 185 ms
100,308 KB
testcase_15 AC 211 ms
111,732 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 272 ms
107,616 KB
testcase_19 AC 274 ms
100,904 KB
testcase_20 WA -
testcase_21 AC 274 ms
101,140 KB
testcase_22 AC 112 ms
103,100 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 75 ms
76,520 KB
testcase_28 AC 93 ms
80,788 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import floor
def read_data():
    N = int(input())
    Ls = list(map(int, input().split()))
    K = int(input())
    return N, Ls, K

def solve(N, Ls, K):
    if K == 1:
        return max(Ls)
    eps = 5*10**-9
    sumLs = sum(Ls)
    maxLs = max(Ls)
    lower = max(maxLs/K, sumLs/(N + K)) - eps
    upper = min(sumLs/K, maxLs) + eps
    while upper - lower > eps and (upper - lower)/lower > eps:
        mid = (upper + lower) / 2
        if sum(floor(L/mid) for L in Ls) >= K:
            lower = mid
        else:
            upper = mid
    return (upper + lower) / 2


N, Ls, K = read_data()
print(solve(N, Ls, K))
0