Trust#3731

Trust

1 секунда
64 мегабајти
Тешко

A large group of people has decided to tackle a set of problems. Each individual in the group is initially assigned a certain number of problems. Among these individuals, there exists a special relationship known as trust. This means one person can delegate some of their problems to another, but not the other way around. These trust relationships are so reliable that a problem can be reassigned multiple times. The group is so interconnected that it is crucial to determine the minimum possible number of problems that the most burdened individual (the one with the highest number of problems) will have after optimally redistributing the problems.

Влез

The input begins with two numbers, and (1 \leq N \leq 100, 0 \leq K \leq N \cdot (N-1)/2), representing the number of people and the number of trust relationships, respectively. Following this, there are numbers in a single line (1 \leq v_i \leq 10^6), which denote the initial number of problems each person has. Then, lines follow, each containing two numbers, and (1 \leq a, b \leq N), indicating that person can trust their problems to person .

Излез

Output a single number, which is the number of problems the most burdened person has after the optimal redistribution.

Примери

Пример 1

Loading
Loading