John and Brus have an interest in team sports tournaments.
They are currently investigating the intermediate standings of a tournament.
They don't know which games have been played so far.
They only know that the tournament is played using the following rules:
Each game is played between two teams and results in either a victory for one team or a draw.
If a team wins a game, it gains w points and its opponent gains no points.
In case of a draw, each team gains d points.
The score of a team is the sum of all the points it has gained from all its games.
There are no restrictions on which teams can play against each other, and each pair of teams can play against each other any number of times (possibly zero).
You are given a int[] points representing the intermediate standings of the tournament.
The i-th element of points is the score of the i-th team.
Return the minimum number of games that could have been played to achieve those standings.
If points doesn't represent a valid state, return -1 instead.
|