According to the issue description, we start from 0th node and will always go to a stage that has the highest value.
I might overlook something from it.
Could anyone give a good direction or test cases for this problem?
Input:
Code: Select all
5
6 6
0 8 9 2 7 5
5 4
5 3
1 5
0 1
0 2
2 1
6 5
0 8 9 2 7 5
5 4
5 3
1 5
0 1
0 2
6 5
0 20 30 40 50 60
0 1
0 2
0 3
0 4
0 5
6 3
0 20 30 40 50 60
0 1
1 5
5 4
2 1
0 1000
0 1
Code: Select all
Case 1: 29 4
Case 2: 9 2
Case 3: 60 5
Case 4: 130 4
Case 5: 1000 1