I had the following sequence
5 1 11 2 8 And I need to make 5 greater than any element in the given sequence with minimum operations..there is a solution for this using while and sorting...etc. I wonder if there is some way to know the solution with the enclosed formula?? I think that I can get 11 — 5 = 6 and then divide 6 by 2 --> 3 and then 5 will be 8 ..but it's not the greatest element then I can just add 1, the answer will be 4 -->(9-5). **** another test case will be 1 8 8 8 i can make the sequence 7 6 6 6 ..the answer is 7-1 = 6 operations . I can analyze this solution into the following : 1 + (3 * 2 ) > 6. where 3 is the occurrence of the biggest element in the sequence.... and 1 is the first element?? Is my thinking wrong?? another test case 16--> number of elements 7 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 I solve it to 990 ..but the optimal is 932!!!!
link to the problem I checked the tutorial ..but couldn't find the problem explanation in it!