A lift can be as slow as 100. Max lift no 5 & Max floor no 100.
So 100*100*5=50000<65535 but >32767.
Use Dijkstra's shortest path.
Here is a sample input.
Code: Select all
4 89
7 2 4 8
3 34 45 56 77
4 23 34 89
0 99
3 99
Code: Select all
1671
Code: Select all
4 89
7 2 4 8
3 34 45 56 77
4 23 34 89
0 99
3 99
Code: Select all
1671