Curefit Interview Question, need help

This was given in our Curefit Interview Test:
A person has to go to a game, they also want to try to eat sandwiches from different restaurants before going. We are given N restaurants that lie on the same street at position pi and the person spends time ti at that respective restaurant. The person takes 1 unit of time to travel 1 unit of path(for example to go from position 1 to position 5 it takes him 4 units of time), assuming the person starts from position 0 and he has to leave for the game in time T, tell the maximum number of restaurants he can visit and he has to come back to the starting place before time T too.
Example N = 3, T = 10 [pi,ti] = [[1,3], [2,2]] (output for this is 2)
1<= N <= 10^5
0 <= T <= 10^9
1<= pi, ti <= 10^8