結果
| 問題 |
No.885 アマリクエリ
|
| コンテスト | |
| ユーザー |
tjake
|
| 提出日時 | 2019-09-14 00:02:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 911 ms / 2,000 ms |
| コード長 | 388 bytes |
| コンパイル時間 | 625 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 105,088 KB |
| 最終ジャッジ日時 | 2024-07-04 10:40:12 |
| 合計ジャッジ時間 | 5,474 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
from heapq import heappop, heappush, heapify
N = int(input())
*A, = map(int, input().split())
Q = int(input())
*X, = map(int, input().split())
B = [-a for a in A]
heapify(B)
def gen(A, B):
res = sum(A)
for x in X:
while x <= -B[0]:
d = -heappop(B)
res += (d % x) - d
heappush(B, -(d % x))
yield res
print(*gen(A, B), sep='\n')
tjake