I tried to solve todays code byte Dream 11 2020 but not getting all test case passed, can u identify problem for the same?

Please send the question link also so that i can see where are you lagging.

Mosina and Mohit are very excited in watching IPL match of MI vs CSK. But problem is that Mosina is fan of MI and Mohit is fan of CSK.So Mohit uses his mind and asks Mosina that if she will give answer to his question then Mohit will support MI otherwise Mosina will have to suport CSK for 19 Sep 2020 match. Mohit’s question is:- As Monu is always interested in making money, so he decided to invest in some kind of precious pearls.But he is confused about when to buy and sell the pearl to get maximum profit. He decided to give this work to you, You have been given some future predictions of N days about the prices of the pearl in the form of an array A where the ith element denotes the price of the ith day. Also, there is a restriction on the number of pearls you can buy or sell. You can sell or buy at most K pearls.And initially you are having zero pearls. You have to find the maximum profit that can be made by buying and selling the pearls Note : You may not engage in multiple transactions at the same time Input Format The first line contains two integers N and K The second line contains N integers where ith integer denotes Ai Constraints 1<= N < 100000 0<= k< 100000 1<=Ai<= 100000 Output Format Print the maximum profit Sample Input 3 2 2 4 1 Sample Output 2

https://hack.codingblocks.com/app/dcb/1735

It’s a problem from live contest. I can help you in this problem after 12 hours.
Hint: Use DP for this problem.

ok now can u help me?

Do you want explanation or code for this problem?

both explanation and code

Have replied it to personal chat, please see it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.