結果
| 問題 |
No.885 アマリクエリ
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-03-18 01:59:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 986 ms / 2,000 ms |
| コード長 | 410 bytes |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 82,036 KB |
| 実行使用メモリ | 107,036 KB |
| 最終ジャッジ日時 | 2025-03-18 01:59:35 |
| 合計ジャッジ時間 | 7,163 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
X=list(map(int,input().split()))
H=[]
for a in A:
heappush(H,-a)
SUM=sum(A)
for x in X:
while True:
if -H[0]>=x:
k=-heappop(H)
u=k%x
SUM-=k-u
heappush(H,-u)
else:
break
print(SUM)
titia