← 返回 meta 的题目列表Ads Ranking Algorithm
类型:online_judge
Assume you are responsible for the ranking algorithm of an advertisement platform. Your task is to rank ads based on a set of metrics. Implement a Python function that takes a list of ads with their metrics and returns a list of ad IDs ordered by rank. The metrics are Click-Through Rate (CTR), Bid, and Expected Clicks. The ranking rules are:
Sort by CTR in descending order.
If CTRs are the same, sort by Bid in descending order.
If Bids are also the same, sort by Expected Clicks in descending order.
Sample Input: Ad List: [{'ad_id': 1, 'CTR': 0.05, 'Bid': 10, 'Expected Clicks': 100}, {'ad_id': 2, 'CTR': 0.04, 'Bid': 12, 'Expected Clicks': 80}, {'ad_id': 3, 'CTR': 0.05, 'Bid': 10, 'Expected Clicks': 200}]
Sample Output: Ad ID list: [3, 1, 2]
Example
Input
[{'ad_id': 1, 'CTR': 0.05, 'Bid': 10, 'Expected Clicks': 100}, {'ad_id': 2, 'CTR': 0.04, 'Bid': 12, 'Expected Clicks': 80}, {'ad_id': 3, 'CTR': 0.05, 'Bid': 10, 'Expected Clicks': 200}]