#K71267. Maximizing Distinct Flower Types
Maximizing Distinct Flower Types
Maximizing Distinct Flower Types
You are given the costs of four types of flowers: Rose, Tulip, Daisy, and Sunflower, represented by P, Q, R, and S respectively. You also have a budget N and a maximum number of flowers K that can be purchased.
Your task is to calculate the maximum number of distinct types of flowers that can be bought without exceeding the budget and the total flower count. In other words, if you denote the total cost by \(T\), then the selections must satisfy \(T \leq N\) and the number of distinct flowers chosen must be at most \(K\). The approach involves selecting the cheapest flower types first.
For example, if the input is 10 20 5 15 35 3
, the optimal selection yields 3 distinct flower types with a total cost of 30.
inputFormat
The input consists of a single line containing six space-separated integers:
- P: Cost of one Rose
- Q: Cost of one Tulip
- R: Cost of one Daisy
- S: Cost of one Sunflower
- N: The budget
- K: Maximum number of flowers you can buy
All inputs are provided via stdin.
outputFormat
Output two space-separated integers:
- The first integer is the maximum number of distinct flower types that can be bought.
- The second integer is the total cost incurred.
The result must be printed to stdout.
## sample10 20 5 15 35 3
3 30