結果

問題 No.885 アマリクエリ
ユーザー AEnAEn
提出日時 2023-07-12 17:55:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,030 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 102,136 KB
最終ジャッジ日時 2023-10-12 08:12:55
合計ジャッジ時間 8,651 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,030 ms
100,928 KB
testcase_01 AC 464 ms
94,676 KB
testcase_02 AC 255 ms
100,420 KB
testcase_03 AC 208 ms
100,016 KB
testcase_04 AC 208 ms
100,396 KB
testcase_05 AC 159 ms
102,136 KB
testcase_06 AC 152 ms
98,460 KB
testcase_07 AC 103 ms
91,868 KB
testcase_08 AC 135 ms
91,804 KB
testcase_09 AC 458 ms
94,672 KB
testcase_10 AC 73 ms
71,196 KB
testcase_11 AC 75 ms
71,292 KB
testcase_12 AC 73 ms
71,116 KB
testcase_13 AC 123 ms
78,092 KB
testcase_14 AC 119 ms
77,852 KB
testcase_15 AC 119 ms
77,772 KB
testcase_16 AC 96 ms
76,740 KB
testcase_17 AC 92 ms
76,632 KB
testcase_18 AC 103 ms
77,176 KB
testcase_19 AC 76 ms
71,292 KB
testcase_20 AC 87 ms
75,996 KB
testcase_21 AC 89 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = list(map(int, input().split()))
hq = []
sm = 0
for i in range(N):
    heappush(hq,-A[i])
    sm += A[i]

for x in X:
    while 1:
        v = -heappop(hq)
        if v>=x:
            sm -= v
            sm += v%x
            heappush(hq,-(v%x))
        else:
            heappush(hq,-v)
            break
    print(sm)
0