DMPG '17 B1 - Whale and Soul

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

In the context of online games, a whale is a player who spends great sums of real money on video games. A certain whale has discovered N different membership options for a game they play, with the i-th costing ci dollars and lasting di days. Keeping in mind that this whale would like to have membership for as long as possible while minimizing how much they swipe their credit card for, can you help them determine the best membership option?

Input Specification

Line 1: a single integer, N.
Lines 2N+1: line i will contain two space separated integers, ci and di.

Output Specification

Two space separated integers, the values ci and di representing the best membership.

Constraints

1N10
1ci,di100

Sample Input

Copy
3
1 4
2 1
1 1

Sample Output

Copy
1 4

Explanation for Sample Output

The first membership lasts for 4 days, which is greater than the duration of the other two memberships (lasting only 1 day).

Since it is the cheapest membership (in this case, the only one) lasting 4 days, the whale should take it.


Comments


  • 4
    Cools  commented on July 18, 2019, 2:53 a.m. edited

    I'm confused, which takes more priority, maximizing the duration of the membership or minimizing the cost? (Example: One option costs 2 and lasts for 2 days and another option costs 4 and lasts for 4 days)


    • 6
      Narcariel  commented on April 9, 2020, 4:43 p.m.

      He always want to take the longest membership. If there is more than one membership with the longest duration, then he chooses the cheapest one.