2015-16 Woburn Challenge Finals - Senior Division

The monkeys have made a booming business out of selling their fur, and
their newfound cash flow has been directed towards purchasing all kinds
of dangerous weapons to be used against the cows. While the cows have
sensed the general fact that the monkeys are about to strike, they are
puzzled by how their enemies could be acquiring the necessary funds.
Watching shipments of nondescript boxes move in and out of the monkeys'
lair has put the entirety of Old MacDonald's farm on edge. To address
the frustrating turn of events, Bo Vine has decided to send an elite
group of
The
Each cow will need to drink from a trough of their choice for exactly 1 minute. The cows certainly like their privacy, so during each minute, each trough can be used by at most one cow. With not much time left until the start of their mission, Bo Vine needs your help to determine the minimum amount of time required for all of them to get a drink, if it's even possible!
In test cases worth
Input Specification
The first line of input consists of three space-separated integers
Output Specification
Output a single integer – the minimum number of minutes required for all
of the cows to drink from a trough, or -1
if it's impossible.
Sample Input 1
4 4 5
13
24
10
13
20
8
14
22
Sample Output 1
3
Sample Explanation 1
The following is one optimal sequence of events:
- 1st minute: The 4th cow drinks from trough
and the nd cow drinks from trough . - 2nd minute: The 3rd cow drinks from trough
. - 3rd minute: The 1st cow drinks from trough
.
Sample Input 2
2 1 0
1
1000000000
999999999
Sample Output 2
-1
Comments