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

Турниры > IMPC16 Group Contests > задача:


35. 50929 - Present from your uncles

IMPC16 Group Contests

Старт: 16.янв.2016 в 10:00:00
Финиш: 16.янв.2016 в 14:00:00
Турнир завершён!
• Турнирная таблица

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

Задачи турнира

• 21. 50873 - Max Frequency
• 22. 50874 - Apartment Building Adm...
• 23. 50875 - Take m-out
• 24. 50876 - He is my cousin
• 25. 50877 - Friendly Queue
• 32. 50926 - School Mail Merge
• 33. 50927 - Health Expenses
• 34. 50928 - War Of Battleships
• 35. 50929 - Present from your ...
• F1. 50841 - My grand-grand-grandfa...
• F2. 50936 - Saving the Soldiers
• F4. 50977 - Gaussian Elimination
• F5. 50978 - Albanian Coders
• F6. 50979 - Minimum access cost for...

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

Если у вас есть предложения или пожелания по работе 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