結果

問題 No.885 アマリクエリ
ユーザー maspymaspy
提出日時 2020-02-06 10:36:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 506 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 31,564 KB
最終ジャッジ日時 2023-10-25 09:53:40
合計ジャッジ時間 8,466 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 879 ms
31,268 KB
testcase_02 AC 237 ms
31,564 KB
testcase_03 AC 232 ms
26,556 KB
testcase_04 AC 228 ms
26,756 KB
testcase_05 AC 116 ms
23,560 KB
testcase_06 AC 105 ms
20,444 KB
testcase_07 AC 70 ms
19,384 KB
testcase_08 AC 91 ms
21,972 KB
testcase_09 AC 876 ms
31,268 KB
testcase_10 AC 30 ms
10,116 KB
testcase_11 AC 30 ms
10,116 KB
testcase_12 AC 30 ms
10,116 KB
testcase_13 AC 35 ms
10,344 KB
testcase_14 AC 36 ms
10,344 KB
testcase_15 AC 35 ms
10,344 KB
testcase_16 AC 33 ms
10,312 KB
testcase_17 AC 31 ms
10,348 KB
testcase_18 AC 32 ms
10,348 KB
testcase_19 AC 31 ms
10,220 KB
testcase_20 AC 31 ms
10,228 KB
testcase_21 AC 32 ms
29,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappop, heappush, heapify

N = int(readline())
*A, = map(int,readline().split())
Q = int(readline())
*X, = map(int,readline().split())

q = [-x for x in A]
heapify(q)
S = sum(A)
answers = []
for x in X:
    while -q[0] >= x:
        a = -heappop(q)
        r = a % x
        S -= (a - r)
        heappush(q, -r)
    answers.append(S)

print('\n'.join(map(str, answers)))
0