try this 2 999 1000 -1000 the correct answer is 999 2999
This is correct answer as the exit is at 999 so in positive direction if a person walks 999 he escapes. This explains first answer. If a person walks in reverse he encounters obstruction at 1000. Thus he reverses to origin and proceeds to exit. Total 1000+1000+999=2999. Hope this helps.