結果
| 問題 |
No.885 アマリクエリ
|
| コンテスト | |
| ユーザー |
torikumino
|
| 提出日時 | 2019-09-19 23:18:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 416 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 82,236 KB |
| 実行使用メモリ | 163,548 KB |
| 最終ジャッジ日時 | 2024-07-21 16:01:12 |
| 合計ジャッジ時間 | 5,411 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 3 |
ソースコード
from collections import *
from heapq import *
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = list(map(int, input().split()))
h = [-e for e in A]
heapify(h)
c = Counter(A)
r = sum(A)
for x in X:
while -h[0] >= x:
v = -heappop(h)
r -= v * c[v]
c[v] = 0
v %= x
if c[v] == 0:
heappush(h, -v)
c[v] += 1
r += v
print(r)
torikumino