結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー | shotoyoo |
提出日時 | 2021-07-06 21:25:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,680 ms / 5,000 ms |
コード長 | 710 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 87,136 KB |
実行使用メモリ | 133,704 KB |
最終ジャッジ日時 | 2023-09-14 04:30:06 |
合計ジャッジ時間 | 25,572 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,497 ms
119,176 KB |
testcase_01 | AC | 1,504 ms
119,332 KB |
testcase_02 | AC | 1,570 ms
120,016 KB |
testcase_03 | AC | 1,541 ms
125,168 KB |
testcase_04 | AC | 1,665 ms
126,248 KB |
testcase_05 | AC | 1,537 ms
125,668 KB |
testcase_06 | AC | 1,471 ms
112,668 KB |
testcase_07 | AC | 1,456 ms
121,792 KB |
testcase_08 | AC | 1,414 ms
124,160 KB |
testcase_09 | AC | 1,680 ms
133,704 KB |
ソースコード
import sys input = 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, heapify h = [] for i in range(n): h.append((-l[i], 1)) heapify(h) index = list(range(q)) ans = [-1]*q index.sort(key=lambda i: k[i]) v = 0 for j in range(q): to = k[index[j]] while v<to: val,i = hpp(h) hp(h, (val*i/(i+1), i+1)) v += 1 ans[index[j]] = -val write("\n".join(map(str, ans)))