結果

問題 No.885 アマリクエリ
ユーザー H3PO4H3PO4
提出日時 2021-03-07 10:07:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 970 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 103,040 KB
最終ジャッジ日時 2024-04-17 08:17:37
合計ジャッジ時間 6,028 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 970 ms
101,472 KB
testcase_01 AC 418 ms
103,040 KB
testcase_02 AC 194 ms
102,528 KB
testcase_03 AC 166 ms
102,912 KB
testcase_04 AC 168 ms
102,912 KB
testcase_05 AC 113 ms
101,888 KB
testcase_06 AC 110 ms
100,640 KB
testcase_07 AC 95 ms
91,944 KB
testcase_08 AC 77 ms
87,168 KB
testcase_09 AC 412 ms
102,400 KB
testcase_10 AC 39 ms
52,864 KB
testcase_11 AC 37 ms
52,736 KB
testcase_12 AC 40 ms
52,096 KB
testcase_13 AC 81 ms
76,160 KB
testcase_14 AC 80 ms
76,800 KB
testcase_15 AC 76 ms
75,212 KB
testcase_16 AC 56 ms
64,768 KB
testcase_17 AC 46 ms
60,160 KB
testcase_18 AC 60 ms
65,920 KB
testcase_19 AC 44 ms
58,496 KB
testcase_20 AC 46 ms
58,752 KB
testcase_21 AC 55 ms
63,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import heapq

input = sys.stdin.buffer.readline

N = int(input())
A = tuple(map(int, input().split()))
Q = int(input())
X = map(int, input().split())
h = [-a for a in A]
heapq.heapify(h)
cur = sum(A)
for x in X:
    while -h[0] >= x:
        a = -heapq.heappop(h)
        cur -= a
        a %= x
        cur += a
        heapq.heappush(h, -a)
    print(cur)
0