You have n identical flowers, which you would like to place into k vases, according to the following rules: • Each flowe
Posted: Fri Jul 01, 2022 5:33 am
You have n identical flowers, which you would like to place intok vases, according to the following rules:• Each flower must be placed in a vase.• The ith vase (where 1 ≤ i ≤ k) must contain at least 1 and atmost fi flowers.
• No two vases are allowed to contain the same number offlowers.Your goal is to assign a number of flowers to each vase followingthe above rules, or to determine that no such assignmentexists.
fi can take any positive integer values.
Design an algorithm which runs in O(k log k) time and achievesthe goal.
• No two vases are allowed to contain the same number offlowers.Your goal is to assign a number of flowers to each vase followingthe above rules, or to determine that no such assignmentexists.
fi can take any positive integer values.
Design an algorithm which runs in O(k log k) time and achievesthe goal.