結果

問題 No.885 アマリクエリ
ユーザー 👑 rin204rin204
提出日時 2022-09-30 23:18:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 916 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 98,352 KB
最終ジャッジ日時 2023-08-24 16:51:28
合計ジャッジ時間 8,644 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 916 ms
94,740 KB
testcase_01 AC 427 ms
94,396 KB
testcase_02 AC 216 ms
94,768 KB
testcase_03 AC 188 ms
94,648 KB
testcase_04 AC 193 ms
94,824 KB
testcase_05 AC 140 ms
96,376 KB
testcase_06 AC 133 ms
98,352 KB
testcase_07 AC 122 ms
92,488 KB
testcase_08 AC 112 ms
91,728 KB
testcase_09 AC 434 ms
94,432 KB
testcase_10 AC 74 ms
71,392 KB
testcase_11 AC 74 ms
71,468 KB
testcase_12 AC 73 ms
71,148 KB
testcase_13 AC 111 ms
77,940 KB
testcase_14 AC 114 ms
77,988 KB
testcase_15 AC 112 ms
77,924 KB
testcase_16 AC 94 ms
76,648 KB
testcase_17 AC 84 ms
76,188 KB
testcase_18 AC 97 ms
76,216 KB
testcase_19 AC 80 ms
75,300 KB
testcase_20 AC 80 ms
75,076 KB
testcase_21 AC 90 ms
75,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

n = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = list(map(int, input().split()))
ans = sum(A)
hq = [-a for a in A]
heapify(hq)
for x in X:
    while -hq[0] >= x:
        a = -heappop(hq)
        ans -= a
        a %= x
        ans += a
        heappush(hq, -a)
    print(ans)
0