結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー norioc
提出日時 2024-08-26 01:13:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,299 ms / 5,000 ms
コード長 464 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 127,164 KB
最終ジャッジ日時 2024-08-26 01:13:27
合計ジャッジ時間 19,444 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop

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

q = []
for i, l in enumerate(L):
    heappush(q, (-l, i))  # (長さ, 棒の本数, 棒インデックス)

kmax = max(K)
ans = [0] * (kmax+1)
cnts = [1] * N
for i in range(1, kmax+1):
    l, p = heappop(q)
    ans[i] = -l
    cnts[p] += 1

    heappush(q, (-L[p] / cnts[p], p))

for k in K:
    print(f'{ans[k]:.10f}')
0