結果
| 問題 | No.885 アマリクエリ |
| コンテスト | |
| ユーザー |
torikumino
|
| 提出日時 | 2019-09-19 23:18:21 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 416 bytes |
| 記録 | |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 85,676 KB |
| 実行使用メモリ | 164,992 KB |
| 最終ジャッジ日時 | 2026-04-03 05:12:25 |
| 合計ジャッジ時間 | 5,313 ms |
|
ジャッジサーバーID (参考情報) |
judge4_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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