ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Data Structures > задача:


50929 - Present from your uncles

Гость
• Вопросы к жюри (2)

Задачи сборника

• 50816 - Largest Sum Path
• 50857 - Nine-Stones Game
• 50837 - Sum is equal to K
• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD
• 50929 - Present from your uncles
• 50863 - Total Access Cost of a BST
• 50979 - Minimum access cost for BST
• 51000 - Book Index
• 51076 - Key person
• 51062 - Fish Pond II
• 51067 - Jumping frog
• 51080 - Deepest Point
• 51079 - Key person - 2

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Present from your uncles

Familia Hamzallari has a tradition. When a young family member graduates from university, just for once in his life, all other relatives and family members collect money for him to build his own business.

Question: You are given the list of people with the amount of money that they can give. Then, you will be given the relationship list. Find the total amount that Andi can take from all his relatives.

Input specification
You will be first given an integer (n) the number of people. Then, in the following n lines, you will be given the amount (integer) that each person can lend (between 0 and 2000). The first number is the amount that the person 1 can give, etc.

The next line contains two numbers the number of relationships given (m) and the ID of person who will take the money from his relatives (k). Then, in the following m lines you will be given two numbers: the relationship chart where people have the IDs from 1 to n where n, m and k are between 1 and 3000.

Output specification:
Show just one integer number, the total amount that Andi can take from all his relatives.

Sample Input I
6
20
10
15
10
30
50
4 5
1 4
5 4
3 6
2 6
Sample Output I
30

Explanation:
There are 6 people. The first person can give 20$, etc. Then, we are given 4 relationships. 1 is the relative of 4 and 5 is the relative of 4, etc. We are asked the amount that is collected for person 5. Two relatives are given for person 5: 1 and 4. And they can give totally 30$.



Для отправки решений необходимо выполнить вход.

www.contester.ru