0

Can i get answer code for this question?

Today you decided to go to the gym. You currently have energy equal to E units. There are N exercises in the gym. Each of these exercises drains Ai amount of energy from your body. You feel tired if your energy reaches 0 or below. Calculate the minimum number of exercises you have to perform such that you become tired. Every unique exercise can only be performed at most 2 times as others also have to use the machines. If performing all the exercises does not make you feel tired, return -1. Parameters: E :: INTEGER The first line contains an integer, E, denoting the Energy. E :: 1 -> 10^5 N :: INTEGER The next line contains an integer, N, denoting the number of exercises. N :: 1 -> 10^5 A :: INTEGER ARRAY Each line i of the N subsequent lines (where 0 ≤ i < N) contains an integer describing the amount of energy drained by i-th exercise. A[i] :: 1 -> 10^5 Test Cases Case#: 1 Input: 6 2 1 2 Output: 4 E = 6 Do 1st exercise 2 times Do 2nd exercise 2 times Hence, total exercises don

31st Jul 2022, 8:15 AM
Umamaheswarao Dulla
2 odpowiedzi
+ 2
Please post your attempt so we can see where you make mistake. Also tag relevant language, you tagged html, but we cant solve this with html.
31st Jul 2022, 9:02 AM
PanicS
PanicS - avatar
+ 2
Umamaheswarao Dulla Asking for an answer code to a question phrased such as yours, makes it look like you want someone to do your homework. This is the reason you have been asked by PanicS to provide your atttempt. We are willing to assist, but on Sololearn, you must also be willing to try to resolve it yourself.
31st Jul 2022, 9:50 AM
Rik Wittkopp
Rik Wittkopp - avatar