結果
| 問題 | No.885 アマリクエリ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-11 23:08:54 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 663 ms / 2,000 ms |
| + 763µs | |
| コード長 | 445 bytes |
| 記録 | |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 95,980 KB |
| 実行使用メモリ | 113,280 KB |
| 最終ジャッジ日時 | 2026-08-18 09:29:32 |
| 合計ジャッジ時間 | 6,920 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
import heapq
N = int(input())
h = list(map(int, input().split()))
Q = int(input())
lsX = list(map(int, input().split()))
h = [-i for i in h]
heapq.heapify(h)
allsum = -sum(h)
for i in range(Q):
x = lsX[i]
while True:
p = heapq.heappop(h)
if p <= -x:
n = (-p)%x
allsum -= (-p)-n
heapq.heappush(h, -n)
else:
heapq.heappush(h, p)
break
print(allsum)