結果
| 問題 | No.885 アマリクエリ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-12 21:32:36 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 462 ms / 2,000 ms |
| + 451µs | |
| コード長 | 577 bytes |
| 記録 | |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 64,640 KB |
| 実行使用メモリ | 87,052 KB |
| 最終ジャッジ日時 | 2026-10-30 20:58:30 |
| 合計ジャッジ時間 | 5,268 ms |
|
ジャッジサーバーID (参考情報) |
judge7_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
## https://yukicoder.me/problems/no/1552
import heapq
def main():
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = list(map(int, input().split()))
answer = sum(A)
queue = []
for a in A:
heapq.heappush(queue, -a)
for x in X:
while len(queue) > 0 and queue[0] <= -x:
a = heapq.heappop(queue)
a = -a
answer -=a
b = a % x
heapq.heappush(queue, -b)
answer += b
print(answer)
if __name__ == "__main__":
main()