#Lutece1431. 不是图论

不是图论

Migrated from Lutece 1431 不是图论

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

给出一个nn个点,mm条边的有向图。每个点上有分值,经过这个点时可以获得一定的分数。

一个点可以经过多次,但是一个点上的分数只能获得一次。

问最多能获得多少分数,起点任选。

1<=nn<=30000,1<=mm<=100000

Input

输入包含多组数据

每组数据第一行为nnmm

接下来nn行,每行有一个数,表示第ii个节点的分值。

接下来mm行,每行有两个数aabb,表示有一条从aabb的有向边

Output

每组数据输出一行,每行仅有一个整数:可以获得的最多的分数。

Samples

5 5
1 1 1 2 3
1 2
2 3
3 1
1 4
1 5
5 3
1 2 3 4 5
1 2
1 3
4 5
6
9

Resources

2016 UESTC Training for Graph