Optimize a search query algorithm to rank Neighbor listings based on distance, price, and host responsiveness.
Implement rank_listings(listings, query, k). Each listing contains an ID and three numeric attributes. Normalize each attribute against the corresponding query maximum, compute a weighted score where lower distance, price, and response time are better, and return the IDs of the best k listings. Break equal scores by original input order. Use a bounded top-k approach rather than sorting every listing when possible.
The function accepts JSON-compatible lists and dictionaries and returns a list of listing ID strings.
def rank_listings(listings, query, k):