結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2025-03-10 00:13:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 724 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 173,668 KB |
最終ジャッジ日時 | 2025-03-10 00:13:55 |
合計ジャッジ時間 | 6,244 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
from heapq import heappush, heappop, heapify INF = 1 << 60 N = int(input()) A = list(map(int, input().split())) Q = int(input()) X = list(map(int, input().split())) min_mod = max(A) + 1 prev_tot = sum(A) q = [-a for a in A] heapify(q) for x in X: tot = prev_tot ys = [] while q and -q[0] >= x: y = -heappop(q) tot -= y m = y % x if m > 0: ys.append(m) tot += m print(tot) prev_tot = tot for y in ys: heappush(q, -y)