結果
問題 | No.885 アマリクエリ |
ユーザー | rlangevin |
提出日時 | 2023-07-05 12:19:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 997 ms / 2,000 ms |
コード長 | 416 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 82,084 KB |
実行使用メモリ | 106,752 KB |
最終ジャッジ日時 | 2024-07-19 06:34:11 |
合計ジャッジ時間 | 6,990 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
from heapq import * N = int(input()) A = list(map(int, input().split())) Q = int(input()) X = list(map(int, input().split())) ans = sum(A) H = [] for a in A: heappush(H, -a) for x in X: while True: now = -heappop(H) if now < x: heappush(H, -now) break else: nex = now % x ans -= now - nex heappush(H, -nex) print(ans)