結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー しらっ亭しらっ亭
提出日時 2015-08-03 11:58:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,931 ms / 5,000 ms
コード長 511 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 49,360 KB
最終ジャッジ日時 2023-09-25 00:45:20
合計ジャッジ時間 27,849 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,779 ms
48,788 KB
testcase_01 AC 1,812 ms
49,212 KB
testcase_02 AC 1,931 ms
48,732 KB
testcase_03 AC 1,888 ms
49,188 KB
testcase_04 AC 1,853 ms
49,360 KB
testcase_05 AC 1,869 ms
49,268 KB
testcase_06 AC 1,686 ms
45,696 KB
testcase_07 AC 1,766 ms
47,676 KB
testcase_08 AC 1,778 ms
45,936 KB
testcase_09 AC 1,670 ms
47,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq


def solve():
    N = int(input())
    L = list(map(int, input().split()))
    Q = int(input())
    K = list(map(int, input().split()))

    h = []

    for i in range(N):
        heapq.heappush(h, (-L[i], 1, i))

    MAX = 500001

    A = [0.0] * MAX
    for j in range(1, MAX):
        l, n, i = heapq.heappop(h)
        A[j] = L[i] / n
        heapq.heappush(h, (-L[i] / (n + 1), n + 1, i))

    for k in K:
        print(A[k])


def main():
    solve()


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