結果
問題 | No.885 アマリクエリ |
ユーザー |
![]() |
提出日時 | 2025-03-10 00:12:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 729 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 174,584 KB |
最終ジャッジ日時 | 2025-03-10 00:12:41 |
合計ジャッジ時間 | 5,419 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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: if min_mod < x: print(prev_tot) continue 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) min_mod = min(min_mod, x)