#K75102. Auction Winner Determination
Auction Winner Determination
Auction Winner Determination
You are given a series of auctions. In each auction, several users submit their bids. Each bid is represented as a pair of integers: the user ID and the bid amount. Your task is to determine the winner of each auction. The winner is the user who submits the highest bid. In case of multiple bids with the same highest value, the winner is the user whose bid appears first in the auction list.
Formally, for an auction with bids \( (u_1, b_1), (u_2, b_2), \ldots, (u_n, b_n) \), the winning bid \( (u, b) \) is chosen such that \[ b = \max_{1 \leq i \leq n} b_i \] and if there exists an index \( j < k \) with \( b_j = b_k = b \), then the bid \( (u_j, b_j) \) is selected.
You need to read the input from standard input (stdin) and write the result to standard output (stdout). Each auction's result should be printed on a new line as two space-separated integers representing the winner's user ID and the winning bid amount.
inputFormat
The input is given in the following format:
T N1 user1 bid1 user2 bid2 ... (N1 bids) N2 ...</p>... NT ... (NT bids)
Here:
- T is the number of auctions.
- For each auction, N is the number of bids (N can be zero).
- Each bid is represented by two integers: the user ID and the bid amount.
If T is 0, no auctions are given and the output should be empty.
outputFormat
For each auction, output a single line containing two space-separated integers:
- The user ID of the winning bid.
- The winning bid amount.
Print the results for each auction in the order they appear in the input. If no auctions are provided (i.e. T = 0), do not print anything.
## sample2
3
101 50
102 60
101 70
4
201 45
202 45
203 50
202 60
101 70
202 60
</p>