結果

問題 No.885 アマリクエリ
ユーザー torikuminotorikumino
提出日時 2019-09-19 23:18:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 86,576 KB
実行使用メモリ 162,216 KB
最終ジャッジ日時 2023-09-28 21:12:22
合計ジャッジ時間 8,623 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 290 ms
107,752 KB
testcase_03 AC 213 ms
108,316 KB
testcase_04 AC 220 ms
108,512 KB
testcase_05 AC 183 ms
108,984 KB
testcase_06 AC 180 ms
106,216 KB
testcase_07 AC 178 ms
96,428 KB
testcase_08 AC 144 ms
92,884 KB
testcase_09 WA -
testcase_10 AC 102 ms
71,396 KB
testcase_11 AC 101 ms
71,728 KB
testcase_12 AC 102 ms
71,560 KB
testcase_13 AC 149 ms
78,668 KB
testcase_14 AC 150 ms
78,360 KB
testcase_15 AC 149 ms
78,752 KB
testcase_16 AC 121 ms
77,420 KB
testcase_17 AC 115 ms
77,056 KB
testcase_18 AC 134 ms
77,456 KB
testcase_19 AC 110 ms
76,152 KB
testcase_20 AC 111 ms
76,024 KB
testcase_21 AC 119 ms
76,732 KB
権限があれば一括ダウンロードができます

ソースコード

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