結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2020-08-28 16:11:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 910 ms / 2,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 856 ms |
コンパイル使用メモリ | 82,120 KB |
実行使用メモリ | 107,460 KB |
最終ジャッジ日時 | 2024-11-13 23:20:47 |
合計ジャッジ時間 | 7,086 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") from heapq import heappop, heappush def getlist(): return list(map(int, input().split())) #処理内容 def main(): N = int(input()) A = getlist() S = sum(A) Q = int(input()) X = getlist() hq = [] for i in A: heappush(hq, -i) # print(hq) for i in range(Q): while -hq[0] >= X[i]: val = (-hq[0]) % X[i] S -= -hq[0] - val heappop(hq) heappush(hq, -val) print(S) if __name__ == '__main__': main()