| Author: | Pavel Mesenev | Time limit: | 3 sec | |
| Input file: | Standard input | Memory limit: | 512 Mb | |
| Output file: | Standard output |
The same farmer as before, the same aggressive cows — but this time the n pastures are not stalls on a tidy line. They are connected by a tangle of fences, ditches and informal cow gossip, so all the farmer can tell you is a number di,j for every pair of pastures: "how far apart I'd call i and j". These numbers need not come from any map or line, and need not satisfy the triangle inequality.
Place C cows into C distinct pastures so that the minimum distance between any two cows is as large as possible.
Output that largest possible minimum distance.
The first line contains two integers n and C. Each of the next n lines contains n integers — row i of the distance matrix di,0… di,n − 1. The matrix is symmetric (di,j = dj,i); the diagonal entries di,i are present but irrelevant and may be ignored.
Print one integer — the maximum achievable minimum distance between two cows.
2 ≤ C ≤ n ≤ 3000
0 ≤ di,j ≤ 109 for i ≠ j, di,j = dj,i
the matrix need not satisfy the triangle inequality
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|