Problem Statement | |||||||||||||
Magical Girls are girls who have magical powers. They fight against evil to protect the Earth. Cosmic enemies have just attacked the Earth, and the Magical Girls are going to fight them. You are given a vector <int> magicalGirlStrength that describes the Magical Girls: for each i, magicalGirlStrength[i] is the strength of one of the girls. You are also given a vector <int> enemyStrength and a vector <int> enemyCount that describe their enemies: for each i, there are enemyCount[i] enemies that each have strength enemyStrength[i]. Each Magical Girl will always fight one enemy at a time. A Magical Girl will defeat her enemy if her strength is greater than or equal to the strength of that enemy. At the beginning of the fight the fatigue of each Magical Girl is 0. Each time a Magical Girl defeats an enemy, her fatigue increases by 1. The Magical Girls want to defeat all the enemies. That is, each of the enemies must be defeated by one of the Magical Girls. Additionally, the Magical Girls want to minimize the maximum fatigue among them. If it is impossible to defeat all of the enemies, return -1. Otherwise, return the smallest F with the following property: the Magical Girls can defeat all enemies in such a way that at the end the fatigue of each girl is at most F. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | The elements of enemyStrength are not necessarily pairwise distinct. | ||||||||||||
Constraints | |||||||||||||
- | magicalGirlStrength will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of magicalGirlStrength will be between 1 and 100, inclusive. | ||||||||||||
- | enemyStrength and enemyCount will each contain between 1 and 50 elements, inclusive. | ||||||||||||
- | enemyStrength and enemyCount will contain the same number of elements. | ||||||||||||
- | Each element of enemyStrength will be between 1 and 100, inclusive. | ||||||||||||
- | Each element of enemyCount will be between 1 and 100, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|
Code: