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

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


50698 - Ayran Delivery

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

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

• 50479 - Bit Compressor
• 50674 - Collecting Eggs
• 50486 - Problems and Programmers
• 50695 - Longest link between neurons
• 50411 - Sum of the Leaves
• 50677 - The Cottage
• 50795 - Trunk
• 50414 - Traffic
• 50698 - Ayran Delivery
• 50978 - Albanian Coders
• 50699 - Fighting Vampires
• 50830 - Sorting BST Nodes
• 50803 - Sum of the depths in BST
• 50805 - Sum of the weights in a BST
• 50712 - Moon algebra
• 50675 - Kruja Boys
• 50415 - The Scientist

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

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

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
IMPC 2014-15 Ind_04-50.

Ayran Delivery

Question: Ramadan is the time when restaurants make a lot of money in Ankara and there are already N restaurants (numbered from 1 to N) with given number of daily visitors. You know how to make the best Ayran in the world. It is so good that all restaurants want to hire you and even if you won’t choose them they are ready to buy Ayran from the restaurant you are working in.

You don’t care about money at all and the only important thing for you is to deliver Ayran to as many people as possible. But the problem is that Ayran loses its original taste if it is delivered to places further than M meters from you.

If there are E direct roads between restaurants select one of them, so that the number of people who could taste your original Ayran is maximum.

Input specification
On the first line there three integers N, M, E (1 ≤ N ≤ 500, M ≤ 10,000, E < 150,000). On the second line there are N integers v_i – number of visitors in restaurant i (vi ≤ 1,000). Each of next E lines contains three integers fi, ti, li, where fi and ti – numbers of restaurants connected, li – the length of the road in meters (1 ≤ fi, ti ≤ 500, 0 < li ≤ 10,000).

Output specification
The number of the restaurant you have chosen. If there are more than one restaurants giving the same result, print the restaurant with the smallest number.

Sample Input I
5 5 4
2 2 2 2 2
1 5 3
5 3 3
2 5 3
4 5 3
Sample Input II
5 3 2
0 2 2 2 2
2 3 2
4 5 2
Sample Output I
5
Sample Output II
2


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

www.contester.ru