#C9383. Highest Bids for Users

    ID: 53470 Type: Default 1000ms 256MiB

Highest Bids for Users

Highest Bids for Users

You are given a series of bids from different users. Each bid consists of a user identifier and a bid amount. Your task is to determine the highest bid submitted by each user and then print the results sorted by the user identifier in alphabetical order.

Formally, given an integer \(n\) representing the number of bids, followed by \(n\) lines, each containing a user id and a bid amount, compute the maximum bid for each unique user. Output each user's id and their highest bid on a separate line.

Note: The user identifiers should be sorted in lexicographical order (alphabetically).

inputFormat

The input is given via standard input (stdin) and consists of:

  1. An integer \(n\) denoting the number of bids.
  2. \(n\) lines follow, each containing a string (user id) and an integer (bid amount) separated by a space.

outputFormat

Output to standard output (stdout) the highest bid for each user, one per line. Each line should contain the user id and their maximum bid, separated by a space. The output should list the users in alphabetical order.

## sample
7
alice 200
bob 150
alice 350
bob 200
charlie 100
alice 100
charlie 150
alice 350

bob 200 charlie 150

</p>