Problem Statement
You are choosing a single internet provider from a list. If you choose the ith provider, you must pay prepaid[i] cents every month, which allows you to use prepaidLimit[i] MB each month. You must pay an additional costPerMB[i] cents for every MB which exceeds the prepaid monthly limit.
Supposing your monthly traffic is equal to monthlyTraffic MB, calculate the minimal monthly cost in cents for this traffic.
Supposing your monthly traffic is equal to monthlyTraffic MB, calculate the minimal monthly cost in cents for this traffic.
Definition
- Class:
- InternetProvider
- Method:
- minimumPayment
- Parameters:
- int[], int[], int[], int
- Returns:
- int
- Method signature:
- int minimumPayment(int[] prepaid, int[] prepaidLimit, int[] costPerMB, int monthlyTraffic)
- (be sure your method is public)
Constraints
- prepaid, prepaidLimit and costPerMB will have the same number of elements.
- prepaid will contain between 1 and 50 elements, inclusive.
- Each element of prepaid will be between 0 and 10000, inclusive.
- Each element of prepaidLimit will be between 0 and 10000000, inclusive.
- Each element of costPerMB will be between 0 and 20, inclusive.
- monthlyTraffic will be between 0 and 1000000, inclusive.
Examples
{0, 5000}{0, 10000000}{5, 0}200
Returns: 1000
The first provider gives us pure pay-per-MB scheme, while the second offers unlimited access. Your traffic is small, so you choose the first one.{0, 5000}{0, 1000000}{5, 0}10000
Returns: 5000
The same two providers, but now you download 10 GB per month - so you choose unlimited access.{97, 922, 1431, 1785, 2352, 2886, 3167, 3850, 4219, 4701, 5336, 5879, 6057, 6806, 7233, 7507, 8115, 8562, 9129, 9823}{1818, 74803, 112667, 153665, 241138, 296981, 316757, 396450, 414014, 475498, 519958, 584161, 623263, 674407, 723778, 759389, 846435, 861465, 939875, 983086}{19, 19, 17, 16, 15, 14, 14, 13, 11, 11, 9, 8, 8, 6, 5, 4, 3, 2, 2, 0}179500
Returns: 2352