4 4 4 4
4 3 3 4
3 3 2 4
2 2 2 4
then what should be the approach for this problem
or atleast can u please explain how did we got 450 in this test case n=4 k=50 100 100 150 300
can u please explain how did we got 35
6 6 7 20
6 5 6 20
5 5 5 20
Did you get a wrong answer or a TLE?
@the_extractor can you please convert this to question i don’t have enough reputation points to convert it to question
I think only you or a mod can convert your answer to a question.
But you can ask a new question instead of converting this.
Initially 100 100 150 300
After 50 operation: 50 100 100 300
Again after 50 operation: 50 50 50 300
Now no two element in array greater than k.
So answer is 450.
@shmabulock : Try this input:
1
5 1
3 9 11 13 25
The answer should be 29 whereas your code gives 25 as the answer.
Can you share, how did you arrive on that answer?
i guess ur approach is failing here :-
n=6 k=4
10 10 11 13 14 20
answer will be 40
In your code, on lines 54 and 55, you’ve written “If the total is greater than x-1 element we can simply say that we will be able to reduce them to k.” How? Can you please explain?
Also, on line 47, I think you meant “modified x-1th element” instead of xth element.
Can anyone who got AC in this question is willing to share his approach ???
You can’t get more than 25