結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー maspymaspy
提出日時 2020-03-24 15:29:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,062 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 52,084 KB
最終ジャッジ日時 2023-08-30 05:30:28
合計ジャッジ時間 28,824 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,003 ms
52,012 KB
testcase_01 AC 2,049 ms
52,064 KB
testcase_02 AC 2,023 ms
52,084 KB
testcase_03 AC 1,993 ms
51,092 KB
testcase_04 AC 2,062 ms
51,208 KB
testcase_05 AC 1,965 ms
51,060 KB
testcase_06 AC 1,869 ms
49,968 KB
testcase_07 AC 1,894 ms
51,132 KB
testcase_08 AC 1,782 ms
48,592 KB
testcase_09 AC 1,828 ms
49,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heapify, heappushpop

N = int(readline())
q = [(-int(x), 1) for x in readline().split()]
Q = int(readline())
K = tuple(map(int, readline().split()))

U = 5 * 10**5
answer = [0] * (U + 1)

heapify(q)

for i in range(1, U + 1):
    x, j = q[0]
    answer[i] = -x
    x *= j
    j += 1
    x /= j
    heappushpop(q, (x, j))

print('\n'.join(str(answer[k]) for k in K))
0