Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Hando

Автор Hando, история, 19 месяцев назад, По-английски

It is an interactive problem.

We have an array $$$a$$$ that we don't know ( and cannot modify ) and we are given an array $$$b$$$ of the same size as $$$a$$$. (length of $$$a$$$ is less then $$$4\ 000$$$).

We need to arrange the elements in the array $$$b$$$ such that the cross product of arrays $$$a$$$ and $$$b$$$ is maximal. ($$$a_1 \ * b_1 \ + \ ... \ + \ a_n \ * b_n$$$ is maximal ).

The interaction consist in giving the array $$$b$$$ and reciveing the cross product with $$$a$$$ every time. (You cannot give an array that is not a permutation of the inital array the we are given $$$b$$$.)

How can we find a rearrangement of array $$$b$$$ that gives the maximal cross product with $$$a$$$, in less than $$$6\ 000$$$ tries?

Edit: I think it is important to mention that $$$a$$$ and $$$b$$$ can have any positive ($$$ > 0$$$) value (and they do not need to be a permutation of $$$n$$$ elements necessarly).

Edit: Also i believe that that jtrh has the right solution, it just needs a little bit of casework when we have in $$$b$$$ multiple elements equal to $$$b[0]$$$ (but I think you can figure out what to do next). My thanks!

Also, thank you to everyone who commented!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится