結果
| 問題 | No.885 アマリクエリ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-29 20:14:09 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 598 ms / 2,000 ms |
| コード長 | 292 bytes |
| 記録 | |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 114,432 KB |
| 最終ジャッジ日時 | 2026-05-29 20:14:17 |
| 合計ジャッジ時間 | 5,278 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge4_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
import heapq
hq=[]
n=int(input());ans=0
for i in list(map(int,input().split())):
ans+=i
heapq.heappush(hq,-i)
input()
for i in list(map(int,input().split())):
while -hq[0]>=i:
q=heapq.heappop(hq)
ans+=q;q=(-q)%i
ans+=q;heapq.heappush(hq,-q)
print(ans)