### PROBLEM LINKS

### DIFFICULTY

SIMPLE

### PREREQUISITES

Simple Math

### PROBLEM

- The default calling rate is
**D rokdas/minute**. - The usage pattern is
**U minutes/month**.

There are **N topups**. They are numbered from **1 to N**.

- The
**i**costs^{th}topup**C**_{i}rokdas - The
**i**lasts^{th}topup**M**_{i}months - The
**i**reduces the calling rate to^{th}topup**R**_{i}rokdas/minute

Find the **topup** that saves the most **rokdas per month**.

### EXPLANATION

We can find the default expense per month in **rokdas/month**

COST = D * U

We can find the expense incurred when using a **topup**

COST_{i}= R_{i}* U

**but wait!** A **topup** costs money and is only valid for **M _{i}** months. This cost can also be split across M

_{i}months to find the cost per month. Hence

COST_{i}= (C_{i}/ M_{i}) + R_{i}* U

We can compare the costs and find the cheapest package.

### CODING COMMENTARY

It is already given that all topups generate a **unique** expense per month value.

There is one edge case where it is possible that none of the available topups produce a monthly cost that is less than the default one. It is clear from the statement that the intended answer in such cases is **0**.

Note that it is possible that there is a plan that generates the **same** cost per month value as the deafult plan. This plan must not be considered!

Note that the **topups** are indexed from **1 to N**, and not **0 to N-1**.

### PSEUDO CODE

e = D * U ans = 0 for i = 1 to N _e = C_{i}/M_{i}+ R_{i}*U if _e < e e = _e ans = i

### SETTERâ€™S SOLUTION

Can be found here.

### TESTERâ€™S SOLUTION

Can be found here.