結果

問題 No.885 アマリクエリ
ユーザー torikumino
提出日時 2019-09-19 23:21:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 418 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 62,196 KB
最終ジャッジ日時 2024-07-21 16:06:39
合計ジャッジ時間 7,499 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from heapq import *
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = list(map(int, input().split()))
h = [-e for e in A]
heapify(h)
c = Counter(A)
r = sum(A)
for x in X:
    while -h[0] >= x:
        v = -heappop(h)
        r -= v * c[v]
        c[v] = 0
        v %= x
        if c[v] == 0:
            heappush(h, -v)
        c[v] += 1
        r += v
    print(r)

0