結果

問題 No.885 アマリクエリ
ユーザー torikumino
提出日時 2019-09-19 23:25:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 931 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,760 KB
実行使用メモリ 102,040 KB
最終ジャッジ日時 2024-07-21 16:16:19
合計ジャッジ時間 5,643 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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)
r = sum(A)
for x in X:
    while -h[0] >= x:
        v = -heappop(h)
        r -= v
        v %= x
        heappush(h, -v)
        r += v
    print(r)
0