結果

問題 No.885 アマリクエリ
ユーザー torikuminotorikumino
提出日時 2019-09-19 23:21:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 418 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 59,984 KB
最終ジャッジ日時 2023-09-28 21:18:19
合計ジャッジ時間 7,941 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 347 ms
29,108 KB
testcase_03 AC 317 ms
24,804 KB
testcase_04 AC 317 ms
24,952 KB
testcase_05 AC 142 ms
20,416 KB
testcase_06 AC 127 ms
11,308 KB
testcase_07 AC 73 ms
24,964 KB
testcase_08 AC 116 ms
19,192 KB
testcase_09 WA -
testcase_10 AC 19 ms
8,512 KB
testcase_11 AC 20 ms
8,520 KB
testcase_12 AC 20 ms
8,492 KB
testcase_13 AC 28 ms
9,096 KB
testcase_14 AC 29 ms
9,052 KB
testcase_15 AC 31 ms
9,216 KB
testcase_16 AC 22 ms
8,704 KB
testcase_17 AC 22 ms
8,672 KB
testcase_18 AC 23 ms
8,716 KB
testcase_19 AC 20 ms
8,788 KB
testcase_20 AC 20 ms
8,644 KB
testcase_21 AC 22 ms
8,712 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