Company: Directi (titan)
Difficulty: hard
Teleporter Run Consider the points 0, 1, ..., n+1 on a number line. There is a teleporter at each of the points 1, 2, ..., n . While you are standing at a point i , you may do any of the following: move one unit to the left, costing 1 coin; move one unit to the right, costing 1 coin; if 1 <= i <= n and the teleporter at point i has not been used yet, use it, costing a[i] coins. When you use it you choose where it sends you: either point 0 or point n+1 . Once a teleporter has been used it is gone and can never be used again. You start at point 0 holding c coins, and you may never spend more coins than you have. Find the maximum number of teleporters you can use. Input Format The first line contains a single integer t , the number of test cases. Each test case is given on two lines: the first line contains two integers n and c , the number of teleporters and the number of coins you start with; the second line contains n integers a[1], a[2], ..., a[n] , where a[i] is the price of th