結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー |
|
提出日時 | 2021-07-06 21:25:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,378 ms / 5,000 ms |
コード長 | 710 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 81,844 KB |
実行使用メモリ | 129,152 KB |
最終ジャッジ日時 | 2024-07-01 12:14:34 |
合計ジャッジ時間 | 22,095 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
import sysinput = lambda : sys.stdin.readline().rstrip()sys.setrecursionlimit(2*10**5+10)write = lambda x: sys.stdout.write(x+"\n")debug = lambda x: sys.stderr.write(x+"\n")writef = lambda x: print("{:.12f}".format(x))n = int(input())l = list(map(int, input().split()))q = int(input())k = list(map(int, input().split()))from heapq import heappop as hpp, heappush as hp, heapifyh = []for i in range(n):h.append((-l[i], 1))heapify(h)index = list(range(q))ans = [-1]*qindex.sort(key=lambda i: k[i])v = 0for j in range(q):to = k[index[j]]while v<to:val,i = hpp(h)hp(h, (val*i/(i+1), i+1))v += 1ans[index[j]] = -valwrite("\n".join(map(str, ans)))