enclosed formula to make an elment greater than any elemnet in given sequence

Revision en2, by Elkhateb, 2022-07-14 14:26:26

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!

Tags help me

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Elkhateb 2022-07-14 14:26:26 169
en1 English Elkhateb 2022-07-14 14:20:25 1011 Initial revision (published)