Can anyone find error in my code for BUILDB

Problem Link: BUILDB Problem - CodeChef
My submission: CodeChef: Practical coding for everyone

You can check your code for this input
1
3 100
1 3 5
2 3 1
Your Output - 2
Correct Output- 3
As at any time minimum tension could be only 0 not less than zero