Problem Statement | |||||||||||||
You are a guitar player and you like to play your guitars, but unfortunately, you broke n strings. Therefore, you have to buy new strings to replace them, and you want to spend as little money as possible. For each brand of strings, you can choose to buy either a package of 6 strings, or 1 or more single strings. You are given a String[] stringCosts, each element of which represents a single brand. Each element is formatted as "PACKAGE SINGLE" (quotes for clarity only), where PACKAGE is the price of a package of 6 strings and SINGLE is the price of a single string. Return the minimum amount of money required to buy at least n strings. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | You are allowed to buy strings from different brands (it sometimes might even be needed to get the lowest price). | ||||||||||||
- | A package just contains 6 equal strings, so 1 package could be replaced by 6 single strings. | ||||||||||||
Constraints | |||||||||||||
- | n will be between 1 and 100, inclusive. | ||||||||||||
- | stringCosts will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of stringCosts will be formatted as "PACKAGE SINGLE" (quotes for clarity only). | ||||||||||||
- | Each PACKAGE will be an integer between 0 and 1000, inclusive, with no extra leading zeroes. | ||||||||||||
- | Each SINGLE will be an integer between 0 and 1000, inclusive, with no extra leading zeroes. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|