| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Father Christmas flymouse
Description After
retirement as contestant from WHU ACM Team, flymouse volunteered to do
the odds and ends such as cleaning out the computer lab for training as
extension of his contribution to the team. When Christmas came,
flymouse played Father Christmas to give gifts to the team members. The
team members lived in distinct rooms in different buildings on the
campus. To save vigor, flymouse decided to choose only one of those
rooms as the place to start his journey and follow directed paths to
visit one room after another and give out gifts en passant until he
could reach no more unvisited rooms. During the days on the team,
flymouse left different impressions on his teammates at the time. Some
of them, like LiZhiXu, with whom flymouse shared a lot of candies,
would surely sing flymouse¡¯s deeds of generosity, while the others,
like snoopy, would never let flymouse off for his idleness. flymouse
was able to use some kind of comfort index to quantitize whether better
or worse he would feel after hearing the words from the gift recipients
(positive for better and negative for worse). When arriving at a room,
he chould choose to enter and give out a gift and hear the words from
the recipient, or bypass the room in silence. He could arrive at a room
more than once but never enter it a second time. He wanted to maximize
the the sum of comfort indices accumulated along his journey. Input The input contains several test cases. Each test cases start with two integers N and M not exceeding 30 000 and 150 000 respectively on the first line, meaning that there were N team members living in N distinct rooms and M direct paths. On the next N lines there are N integers, one on each line, the i-th of which gives the comfort index of the words of the team member in the i-th room. Then follow M lines, each containing two integers i and j indicating a directed path from the i-th room to the j-th one. Process to end of file. Output For each test case, output one line with only the maximized sum of accumulated comfort indices. Sample Input Sample Output Hint 32-bit signed integer type is capable of doing all arithmetic. Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2006 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator