結果

問題 No.885 アマリクエリ
ユーザー ntuda
提出日時 2025-05-03 12:11:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 307 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 95,004 KB
最終ジャッジ日時 2025-05-03 12:11:51
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 12 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

N = int(input())
A = list(map(int,input().split()))
ans = sum(A)
Q = [-a for a in A]
heapify(Q)
_ = int(input())
X = list(map(int,input().split()))

for x in X:
    while -Q[0] >= x:
        y = -heappop(Q)
        yx = y % x
        ans -= y + yx
        heappush(Q,-yx)
    print(ans)
0