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

Правка en1, от Elkhateb, 2022-07-14 14:20:25

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 is there is someway to know the solution with 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 analysis this solution into the following : 1 + (3 * 2 ) > 6. where 3 is the occurence 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!!!!

Теги help me

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Elkhateb 2022-07-14 14:26:26 169
en1 Английский Elkhateb 2022-07-14 14:20:25 1011 Initial revision (published)