結果

問題 No.885 アマリクエリ
ユーザー tjaketjake
提出日時 2019-09-14 00:02:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,007 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 98,748 KB
最終ジャッジ日時 2023-09-17 15:37:15
合計ジャッジ時間 6,942 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,007 ms
97,424 KB
testcase_01 AC 445 ms
97,356 KB
testcase_02 AC 248 ms
97,152 KB
testcase_03 AC 212 ms
96,892 KB
testcase_04 AC 210 ms
97,052 KB
testcase_05 AC 162 ms
98,748 KB
testcase_06 AC 155 ms
97,640 KB
testcase_07 AC 133 ms
94,316 KB
testcase_08 AC 130 ms
93,888 KB
testcase_09 AC 452 ms
97,024 KB
testcase_10 AC 80 ms
71,448 KB
testcase_11 AC 78 ms
71,632 KB
testcase_12 AC 79 ms
71,388 KB
testcase_13 AC 115 ms
77,912 KB
testcase_14 AC 115 ms
77,572 KB
testcase_15 AC 117 ms
77,552 KB
testcase_16 AC 98 ms
76,644 KB
testcase_17 AC 87 ms
75,996 KB
testcase_18 AC 96 ms
76,768 KB
testcase_19 AC 82 ms
75,568 KB
testcase_20 AC 86 ms
75,696 KB
testcase_21 AC 93 ms
76,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

B = [-a for a in A]
heapify(B)
def gen(A, B):
    res = sum(A)
    for x in X:
        while x <= -B[0]:
            d = -heappop(B)
            res += (d % x) - d
            heappush(B, -(d % x))
        yield res
print(*gen(A, B), sep='\n')
0