結果

問題 No.885 アマリクエリ
ユーザー kohei2019kohei2019
提出日時 2022-05-11 23:08:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 996 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 875 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 98,532 KB
最終ジャッジ日時 2023-09-26 14:49:30
合計ジャッジ時間 9,271 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 996 ms
95,052 KB
testcase_01 AC 470 ms
94,480 KB
testcase_02 AC 264 ms
95,260 KB
testcase_03 AC 218 ms
94,896 KB
testcase_04 AC 213 ms
94,888 KB
testcase_05 AC 158 ms
96,484 KB
testcase_06 AC 154 ms
98,532 KB
testcase_07 AC 121 ms
92,832 KB
testcase_08 AC 131 ms
91,624 KB
testcase_09 AC 475 ms
94,736 KB
testcase_10 AC 69 ms
71,492 KB
testcase_11 AC 70 ms
71,544 KB
testcase_12 AC 70 ms
71,412 KB
testcase_13 AC 116 ms
78,256 KB
testcase_14 AC 123 ms
77,940 KB
testcase_15 AC 115 ms
78,300 KB
testcase_16 AC 95 ms
76,620 KB
testcase_17 AC 85 ms
76,616 KB
testcase_18 AC 101 ms
77,400 KB
testcase_19 AC 75 ms
75,568 KB
testcase_20 AC 83 ms
75,972 KB
testcase_21 AC 85 ms
75,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N = int(input())
h = list(map(int, input().split()))
Q = int(input())
lsX = list(map(int, input().split()))

h = [-i for i in h]
heapq.heapify(h)

allsum = -sum(h) 
for i in range(Q):
    x = lsX[i]
    while True:
        p = heapq.heappop(h)
        if p <= -x:
            n = (-p)%x
            allsum -= (-p)-n
            heapq.heappush(h, -n)
        else:
            heapq.heappush(h, p)
            break
    print(allsum)
0