#K1216. Max Sweetness per Dollar
Max Sweetness per Dollar
Max Sweetness per Dollar
Bob loves candy, but he has a strict budget. He is looking at multiple candy packs where each pack has a price and a corresponding sweetness value. Bob's goal is to maximize the amount of sweetness he gets per dollar spent. In other words, he is interested in finding a candy pack with the maximum sweetness per dollar ratio.
Given the number of candy packs \(M\) and the details of each pack represented as a pair of integers \(P_i\) (price) and \(S_i\) (sweetness), your task is to compute the maximum integer value of \(\frac{S_i}{P_i}\) among all packs. Note that the result should be the floor value of the actual ratio.
Example:
Input: 3 4 16 2 6 8 24</p>Output: 4
inputFormat
The first line contains an integer \(M\) representing the number of candy packs. The next \(M\) lines each contain two space-separated integers \(P_i\) and \(S_i\) denoting the price and sweetness of the \(i^{th}\) candy pack.
Input Format:
M P1 S1 P2 S2 ... PM SM
outputFormat
Output a single integer — the maximum integer value of the sweetness per dollar ratio among all candy packs.
Output Format:
result## sample
3
4 16
2 6
8 24
4