You are given an integer array costs, where visiting index i costs costs[i], and an array queries where queries[k] = [start, budget].
For each query you begin at index start and move forward one index at a time, paying the cost of every index you visit, including start itself. You stop before the first index you can no longer afford.
Return an array with one answer per query: the largest index j such that costs[start] + costs[start+1] + ... + costs[j] <= budget. If even costs[start] exceeds the budget, the answer for that query is -1.
Input: costs = [3,1,4,2,5], queries = [[1,7],[0,3],[2,3]]
Output: [3,0,-1]
Explanation: From index 1 with budget 7: 1 + 4 + 2 = 7 reaches index 3 (adding costs[4] = 5 would exceed 7). From index 0 with budget 3: costs[0] = 3 fits exactly but 3 + 1 = 4 does not, so the answer is 0. From index 2 with budget 3: costs[2] = 4 > 3, so the answer is -1.
costs.length ≤105costs[i] ≤104queries.length ≤5⋅104queries[k] =[start,budget] with 0≤start< costs.length and 0≤budget≤109