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

please help me with this problem

Правка en1, от MVP_DukeX, 2024-10-03 13:38:32

There is an array with size $$$N$$$. Given an integer $$$K$$$, each time you can choose two element in this array, let's call them $$$x$$$ and $$$y$$$, remove them and add $$$K-x-y$$$ into the array. After $$$n-1$$$ operations, there is only one element in the array. What's the maximum possible value of this element?

There are Q queries, each queries contains an integer K. Answer the queries indepently.

$$$N, Q <= 300000 $$$

$$$K, a[i] <= 10^9$$$

Sample:

$$$N=4$$$

$$$a=[1\ 2\ 3\ 4]$$$

$$$K=[3\ 4\ 5\ 6\ 7]$$$

$$$Ans=[7\ 6\ 5\ 4\ 5]$$$

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский MVP_DukeX 2024-10-03 16:11:24 287 Tiny change: ' can left 3-0-(-4)=7 which is ' -> ' can left $3-0-(-4)=7$ which is '
en1 Английский MVP_DukeX 2024-10-03 13:38:32 552 Initial revision (published)