結果
| 問題 | No.885 アマリクエリ |
| コンテスト | |
| ユーザー |
tjake
|
| 提出日時 | 2019-09-14 00:02:29 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 544 ms / 2,000 ms |
| + 367µs | |
| コード長 | 388 bytes |
| 記録 | |
| コンパイル時間 | 264 ms |
| コンパイル使用メモリ | 95,632 KB |
| 実行使用メモリ | 118,784 KB |
| 最終ジャッジ日時 | 2026-08-06 08:18:39 |
| 合計ジャッジ時間 | 5,517 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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