https://code.google.com/codejam/contest/12224486/dashboard
Simple. For each row, greedy to get the maximum number.
Sort all probabilities. Then match the smallest one with the biggest one.
Not so simple.
Just consider of this pattern:
IIIIIIIIIIIIII
//////////////
OOOOOOOOOOOOOO
//////////////
IIIIIIIIIIIIII
...
For each /
on border, it will create 1 I/O
.
For each /
in middle, it will create 3 I/O
.
This problem is hard, very hard, maybe the hardest problem in Codejam to I/O for Women.
Using Floyd algorithm to calculate distance between any nodes.
Then, for each edge, for each possible position, check the minimax.
The problem is, what's the possible position?
Assume the verticals of the edge is u, v
and its length is l
.
Assume the distance between u and any point is a[]
, distance
between v and any point is b[]
.
Then, all possible positions x should satisfies a[i]+x = b[j]+(l-x)
.
So, just iterate i and j, to calculate all possible x, and find the minimax.