Условие:
You are a professional trainer of
N
N squirrels. After a long period of training, they have become remarkably intelligent — they even have their own currency to buy their favorite nuts. You know how many nuts each squirrel has (the i-th squirrel has
A
i
A
i
nuts). You've noticed that the overall unhappiness of the squirrels is influenced by the
M
a
x
(
A
1
,
A
2
,
A
3
,
.
.
.
,
A
n
)
Max(A
1
,A
2
,A
3
,...,A
n
), so you want to minimize this number. You can perform one operation: take a nut from the
i
−
t
h
i−th squirrel and give it to the
j
−
t
h
j−th squirrel, which will cost you
B
i
B
i
units of currency. You can perform this action as many times as you want, as long as you can afford it. Initially, you have
K
K units of currency. Calculate and print the minimum unhappiness level you can achieve.
Input Format
The first line contains two integers —
N
N and
K
K(
1
≤
N
≤
2
∗
1
0
5
1≤N≤2∗10
5
,
0
≤
K
≤
1
0
18
0≤K≤10
18
).
The second line contains
N
N integers
A
i
A
i
(
0
≤
A
i
≤
1
0
6
0≤A
i
≤10
6
).
The third line contains
N
N integers
B
i
B
i
(
0
≤
B
i
≤
1
0
6
0≤B
i
≤10
6
).
Решение:
Для решения задачи, давайте разберем шаги, которые нам нужно выполнить. 1. Понимание задачи: Нам нужно минимизировать максимальное количество орехов у белок, используя определенное количество валюты для передачи орехов от одной белки к другой. Мы можем передавать орехи, но это стоит денег, и у нас есть ограниченный бюджет. 2. Входные данные: - N — количество белок. - K — количество валюты, которую мы можем использовать. - A — массив, где A[i] — количество орехов у i-й белки. - B — массив, где B[i] — стоимость передачи одного ореха от i-й белки. 3. Определение максимального количества о...
7. : После выполнения кода, мы получим минимальный уровень несчастья, который можно достичь, передавая орехи между белками с учетом имеющейся валюты.