#P4742. [Wind Festival] Running In The Sky
[Wind Festival] Running In The Sky
Description
After a day of activities, all the students stop to admire the kites lit up under the night sky. Curtis Nishikino wants to experience it from a closer view, so she runs onto the kites in the sky (which is a bit unbelievable for a girl)! Each kite’s light has a brightness . Because of the wind, some kites get tangled together. This does not ruin the mood—tangled kites pool their lights to form a brighter light source.
Curtis Nishikino already knows some relations between the kites: for a given pair of kites , she can run from to , but she cannot return.
Now, please help her find a path (she may reach a kite multiple times, but only the first arrival counts toward the light she experiences) so that she experiences the maximum total brightness. Also tell her the maximum brightness of a single kite on this path. If there are multiple paths that achieve the same total brightness, output the answer that yields the maximum single-kite brightness.
Input Format
The first line contains two integers and . Here, is the number of kites, and is the number of relation pairs.
The next line contains integers .
Each of the next lines contains two integers and , meaning Curtis can run from to .
Output Format
Output one line with two integers: the total brightness Curtis experiences along the computed path, and the maximum brightness of a single kite on that path.
5 5
8 9 11 6 7
1 2
2 3
2 4
4 5
5 2
41 11
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, $0<n\le2\times10^5,\ 0<m\le5\times10^5,\ 0<k_i\le200$.
Translated by ChatGPT 5
京公网安备 11011102002149号