結果

問題 No.885 アマリクエリ
ユーザー None
提出日時 2021-04-04 21:03:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 975 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 82,852 KB
実行使用メモリ 107,032 KB
最終ジャッジ日時 2024-12-28 08:03:49
合計ジャッジ時間 6,594 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
N=int(input())
A=list(map(int, input().split()))
Q=int(input())
X=list(map(int, input().split()))

S=sum(A)
H=[]
for a in A:
    heappush(H,-a)

for x in X:
    while -H[0]>=x:
        a=-heappop(H)
        S-=a
        a%=x
        S+=a
        heappush(H,-a)
    print(S)
0