結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,968 ms
52,144 KB
testcase_01 AC 1,963 ms
52,060 KB
testcase_02 AC 1,954 ms
52,156 KB
testcase_03 AC 1,899 ms
51,024 KB
testcase_04 AC 1,972 ms
50,976 KB
testcase_05 AC 2,030 ms
51,096 KB
testcase_06 AC 1,791 ms
49,928 KB
testcase_07 AC 1,932 ms
50,996 KB
testcase_08 AC 1,818 ms
48,620 KB
testcase_09 AC 1,788 ms
49,308 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, heapreplace

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
    heapreplace(q, (x, j))

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