結果
| 問題 |
No.885 アマリクエリ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-30 23:18:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 990 ms / 2,000 ms |
| コード長 | 321 bytes |
| コンパイル時間 | 324 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 102,528 KB |
| 最終ジャッジ日時 | 2024-12-23 01:01:21 |
| 合計ジャッジ時間 | 6,801 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
from heapq import *
n = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = list(map(int, input().split()))
ans = sum(A)
hq = [-a for a in A]
heapify(hq)
for x in X:
while -hq[0] >= x:
a = -heappop(hq)
ans -= a
a %= x
ans += a
heappush(hq, -a)
print(ans)