結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー titiatitia
提出日時 2021-12-26 03:28:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,091 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 903 ms
コンパイル使用メモリ 11,720 KB
実行使用メモリ 48,012 KB
最終ジャッジ日時 2023-10-22 08:03:10
合計ジャッジ時間 29,265 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,889 ms
48,012 KB
testcase_01 AC 2,037 ms
48,008 KB
testcase_02 AC 1,998 ms
48,008 KB
testcase_03 AC 2,091 ms
47,612 KB
testcase_04 AC 2,026 ms
47,612 KB
testcase_05 AC 2,043 ms
47,612 KB
testcase_06 AC 1,801 ms
45,500 KB
testcase_07 AC 1,829 ms
46,100 KB
testcase_08 AC 1,711 ms
45,384 KB
testcase_09 AC 1,808 ms
46,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 解説 http://rsujskf.s602.xrea.com/?yukicoder_68
# を見ました。
# easyとは違う解法なのは驚き。特に、二分探索ではない方法があるというのは意外でした。

import sys
input = sys.stdin.readline
import heapq

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

H=[]
for l in L:
    heapq.heappush(H,(-l,1))

ANS=[0]*(5*10**5+1)

for i in range(1,5*10**5+1):
    x,y=heapq.heappop(H)
    x=-x
    ANS[i]=x
    moto=x*y
    y+=1

    heapq.heappush(H,(-moto/y,y))

for k in K:
    print(ANS[k])
0