結果

問題 No.885 アマリクエリ
コンテスト
ユーザー Kiri8128
提出日時 2021-04-05 02:27:51
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 581 ms / 2,000 ms
コード長 457 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 363 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 109,696 KB
最終ジャッジ日時 2026-06-03 08:44:29
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = lambda: sys.stdin.readline().rstrip()
from heapq import heappush, heappop
H = []
hpush = lambda x: heappush(H, -x)
hpop = lambda: -heappop(H)
N = int(input())
A = [int(a) for a in input().split()]
ans = 0
for a in A:
    ans += a
    hpush(a)

Q = int(input())
X = [int(a) for a in input().split()]
for x in X:
    while -H[0] >= x:
        a = hpop()
        ans -= a
        a %= x
        hpush(a)
        ans += a
    print(ans)
    
0