Company: Groww_13nov
Difficulty: medium
Kingdom Description A kingdom has N cities in a row, numbered 1 to N . You begin in city 1 with T units of energy and you want to reach city N . E[i] is the energy city i charges you for being there. You pay E[i] every time you are in city i , including city 1 where you start and city N where you finish. From city i a single move takes you to any one of the next K cities -- i+1 , i+2 , ..., i+K -- as long as the destination exists. Moves always go forward. A journey is successful when the total energy it charges is at most T . Two journeys are different when the sequence of cities they visit is different. Report how many different successful journeys from city 1 to city N exist. Complete the function countWays in the editor below. Function Signature int countWays(int N, long long T, int K, vector<int> E); Input The input is read from standard input as whitespace-separated integers, in this order: N , T and K on the first line. N integers on the second line, the array E , with E[i