function second_price_auction(bids): # bids: {advertiser: bid_amount}

   ranked = sort(bids.values(), descending=true)
   winner = argmax(bids)
   price_paid = ranked[1] if length(ranked) > 1 else ranked[0]
   return winner, price_paid # winner pays the second-highest bid, not their
 own
