結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-08 20:34:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,917 ms / 5,000 ms
コード長 680 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 27,196 KB
最終ジャッジ日時 2024-04-25 23:38:53
合計ジャッジ時間 33,545 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
27,196 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 727 ms
16,936 KB
testcase_03 AC 1,304 ms
22,460 KB
testcase_04 AC 1,917 ms
23,768 KB
testcase_05 AC 1,870 ms
23,644 KB
testcase_06 AC 1,580 ms
23,644 KB
testcase_07 AC 1,804 ms
27,092 KB
testcase_08 AC 1,810 ms
26,964 KB
testcase_09 AC 1,582 ms
26,960 KB
testcase_10 AC 1,674 ms
24,468 KB
testcase_11 AC 1,769 ms
24,240 KB
testcase_12 AC 1,461 ms
21,888 KB
testcase_13 AC 1,665 ms
25,532 KB
testcase_14 AC 1,703 ms
26,100 KB
testcase_15 AC 1,342 ms
24,500 KB
testcase_16 AC 1,185 ms
23,648 KB
testcase_17 AC 1,127 ms
23,756 KB
testcase_18 AC 1,106 ms
23,644 KB
testcase_19 AC 1,102 ms
26,836 KB
testcase_20 AC 1,113 ms
27,008 KB
testcase_21 AC 1,114 ms
26,836 KB
testcase_22 AC 100 ms
24,472 KB
testcase_23 AC 1,050 ms
24,280 KB
testcase_24 AC 31 ms
11,008 KB
testcase_25 AC 69 ms
11,264 KB
testcase_26 AC 45 ms
11,008 KB
testcase_27 AC 41 ms
11,008 KB
testcase_28 AC 328 ms
13,516 KB
testcase_29 AC 182 ms
12,160 KB
testcase_30 AC 71 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import math


def compute_max_length(n, ls, k):
    if k == 1:
        return max(ls)
    eps = 10.0 ** (-10)
    high = 10.0 ** 9
    low = eps
    while high - low > eps and (high - low) / low > eps:
        mid = (high + low) / 2
        num_of_sticks = sum(math.floor(l / mid) for l in ls)
        if num_of_sticks >= k:
            low = mid
        else:
            high = mid
    return (high + low) / 2


def main():
    n = int(input())
    ls = array.array("L", map(int, input().split()))
    k = int(input())
    print("{:.16f}".format(compute_max_length(n, ls, k)))


if __name__ == '__main__':
    main()
0