#P2573. [SCOI2012] 滑雪

    ID: 1590 远端评测题 5000ms 125MiB 尝试: 9 已通过: 1 难度: 7 上传者: 标签>图论2012四川各省省选排序生成树

[SCOI2012] 滑雪

Description

a180285 is very fond of skiing. He comes to a snowy mountain with mm ski tracks and nn intersections between tracks (which are also scenic spots). Each scenic spot has an index i (1in)i\space (1 \le i \le n) and a height hih_i.

a180285 can ski from spot ii to spot jj if and only if there is an edge between ii and jj, and the height at ii is not less than that at jj. Unlike other ski enthusiasts, a180285 prefers to visit as many spots as possible using the shortest skiing route. If he only visits the spots along a single path, he feels the number is too small.

So a180285 takes out his portable time capsule. It is a magical medicine that, after being taken, can immediately return him to the last visited spot (this does not require movement and is not counted in a180285’s skiing distance).

Note that this magical medicine can be taken consecutively, allowing him to return to spots visited a longer time ago (for example, the previous, the one before that, or the one even earlier). Now, a180285 stands at spot 11, gazing at the goals downhill, full of excitement. He wants to know, ignoring the consumption of time capsules, the plan that uses the shortest skiing distance to reach as many scenic spots as possible (i.e., among all plans that maximize the number of visited spots, minimize the total skiing distance). Can you help him find the minimum distance and the number of spots?

Input Format

The first line contains two integers n,mn, m.
The next line contains nn integers hih_i, representing the height of each scenic spot.

Then there are mm lines, each with three integers u,v,ku, v, k, indicating there is a track of length kk between spots uu and vv.

Output Format

Output one line with two integers: the maximum number of scenic spots a180285 can reach, and the minimum total skiing distance in that case.

3 3 
3 2 1 
1 2 1 
2 3 1 
1 3 10 
3 2

Hint

For 30%30\% of the testdata, 1n20001 \le n \le 2000.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1m1061 \le m \le 10^6, 1hi1091 \le h_i \le 10^9, 1ki1091 \le k_i \le 10^9.

Translated by ChatGPT 5