結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2020-12-24 00:57:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 999 ms / 2,000 ms |
コード長 | 317 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,588 KB |
実行使用メモリ | 101,192 KB |
最終ジャッジ日時 | 2024-09-21 16:40:16 |
合計ジャッジ時間 | 6,650 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
import heapq N = int(input()) A = list(map(lambda x: -int(x), input().split())) Q = int(input()) X = list(map(int, input().split())) heapq.heapify(A) ans = -sum(A) for x in X: while x <= -A[0]: a = -heapq.heappop(A) ans -= a heapq.heappush(A, -(a % x)) ans += a % x print(ans)