HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Graph problems and UF > problem:


50929 - Present from your uncles

Guest
• Review clarifications (2)

Section problems

• 50841 - My grand-grand-grandfather
• 50697 - Base Stations
• 50695 - Longest link between neurons
• 50414 - Traffic
• 50698 - Ayran Delivery
• 50978 - Albanian Coders
• 50699 - Fighting Vampires
• 50857 - Nine-Stones Game
• 50929 - Present from your uncles
• 51076 - Key person
• 51080 - Deepest Point
• 51079 - Key person - 2
• 50464 - From Tirana to Durres
• 50691 - The traveling salesman prob...
• 50701 - Cell Removal
• 50703 - The Shortest Path
• 50704 - Connected?

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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