K-value

아직 제출이 없습니다시간 제한6초메모리 제한256 MB

문제

There is a country with NN cities. All these cities are connected by weighted roads such that there is one simple route between any two cities.

Consider all simple paths which contain between LL and RR roads (both inclusive). Your task is to find the path among them which has the minimum possible kk-value.

The kk-value of a simple path is calculated as follows. Let the number of roads in the path be rr. Take the list of weights of all rr roads in the path and sort it in non-descending order. The kk-value is then the element number (r/k+1\lfloor r / k \rfloor + 1) of this list.

입력

The first line of input contains a single integer NN (1N1051 \le N \le 10^5). Each of the following (N1)(N - 1) lines contains three integers aa, bb and ww which represent two cities connected by a road and the weight of the road (1a,bN1 \le a, b \le N, aba \ne b, 1w1091 \le w \le 10^9).

The next line contains three integers kk, LL and RR (1<k<501 < k < 50, 1LR501 \le L \le R \le 50).

출력

Print the minimum possible kk-value of a path which contains between LL and RR roads, inclusive. If no such path exists, print 1-1.