結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-21 23:29:42
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 545 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,168 KB
実行使用メモリ 31,248 KB
最終ジャッジ日時 2023-09-22 21:06:01
合計ジャッジ時間 20,375 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
31,248 KB
testcase_01 AC 16 ms
8,440 KB
testcase_02 AC 383 ms
16,580 KB
testcase_03 AC 706 ms
24,216 KB
testcase_04 AC 944 ms
29,056 KB
testcase_05 AC 959 ms
29,036 KB
testcase_06 AC 998 ms
29,044 KB
testcase_07 AC 962 ms
30,148 KB
testcase_08 AC 960 ms
30,148 KB
testcase_09 AC 1,134 ms
30,260 KB
testcase_10 AC 833 ms
26,012 KB
testcase_11 AC 907 ms
28,348 KB
testcase_12 AC 857 ms
25,568 KB
testcase_13 AC 875 ms
28,800 KB
testcase_14 AC 911 ms
29,188 KB
testcase_15 AC 970 ms
27,096 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 #

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 = 4*10**-9
    lower = max(Ls)/K - eps
    upper = min(sum(Ls)/K, max(Ls)) + eps
    while upper - lower > eps:
        mid = (upper * lower)**0.5
        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