結果

問題 No.885 アマリクエリ
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-24 00:57:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,007 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 100,628 KB
最終ジャッジ日時 2023-10-21 15:25:41
合計ジャッジ時間 7,787 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,007 ms
99,496 KB
testcase_01 AC 427 ms
95,764 KB
testcase_02 AC 200 ms
95,272 KB
testcase_03 AC 172 ms
95,036 KB
testcase_04 AC 177 ms
94,244 KB
testcase_05 AC 118 ms
100,628 KB
testcase_06 AC 112 ms
100,592 KB
testcase_07 AC 97 ms
90,212 KB
testcase_08 AC 87 ms
90,500 KB
testcase_09 AC 436 ms
95,764 KB
testcase_10 AC 40 ms
53,476 KB
testcase_11 AC 40 ms
53,476 KB
testcase_12 AC 40 ms
53,476 KB
testcase_13 AC 87 ms
75,884 KB
testcase_14 AC 86 ms
75,884 KB
testcase_15 AC 85 ms
75,888 KB
testcase_16 AC 63 ms
65,932 KB
testcase_17 AC 50 ms
61,072 KB
testcase_18 AC 66 ms
65,932 KB
testcase_19 AC 46 ms
59,108 KB
testcase_20 AC 48 ms
61,072 KB
testcase_21 AC 58 ms
65,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N = int(input())
A = list(map(lambda x: -int(x), input().split()))
Q = int(input())
X = list(map(int, input().split()))

heapq.heapify(A)
ans = -sum(A)
for x in X:
    while x <= -A[0]:
        a = -heapq.heappop(A)
        ans -= a
        heapq.heappush(A, -(a % x))
        ans += a % x
    print(ans)
0