結果

問題 No.885 アマリクエリ
ユーザー rlangevinrlangevin
提出日時 2023-07-05 12:19:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,050 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 102,120 KB
最終ジャッジ日時 2023-09-26 12:01:14
合計ジャッジ時間 9,877 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,050 ms
101,192 KB
testcase_01 AC 498 ms
94,740 KB
testcase_02 AC 266 ms
100,688 KB
testcase_03 AC 220 ms
100,100 KB
testcase_04 AC 220 ms
100,288 KB
testcase_05 AC 170 ms
102,120 KB
testcase_06 AC 163 ms
98,560 KB
testcase_07 AC 109 ms
91,984 KB
testcase_08 AC 145 ms
91,640 KB
testcase_09 AC 496 ms
94,536 KB
testcase_10 AC 76 ms
71,292 KB
testcase_11 AC 75 ms
71,080 KB
testcase_12 AC 77 ms
71,416 KB
testcase_13 AC 122 ms
78,068 KB
testcase_14 AC 123 ms
77,872 KB
testcase_15 AC 121 ms
77,868 KB
testcase_16 AC 100 ms
76,580 KB
testcase_17 AC 92 ms
76,292 KB
testcase_18 AC 104 ms
77,328 KB
testcase_19 AC 76 ms
71,384 KB
testcase_20 AC 87 ms
76,028 KB
testcase_21 AC 89 ms
76,192 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)
H = []
for a in A:
    heappush(H, -a)

for x in X:
    while True:
        now = -heappop(H)
        if now < x:
            heappush(H, -now)
            break
        else:
            nex = now % x
            ans -= now - nex
            heappush(H, -nex)

    print(ans)
0