結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2023-07-12 17:55:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,023 ms / 2,000 ms |
コード長 | 429 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,156 KB |
実行使用メモリ | 107,208 KB |
最終ジャッジ日時 | 2024-09-14 07:19:05 |
合計ジャッジ時間 | 6,743 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
from heapq import heappop, heappush N = int(input()) A = list(map(int, input().split())) Q = int(input()) X = list(map(int, input().split())) hq = [] sm = 0 for i in range(N): heappush(hq,-A[i]) sm += A[i] for x in X: while 1: v = -heappop(hq) if v>=x: sm -= v sm += v%x heappush(hq,-(v%x)) else: heappush(hq,-v) break print(sm)