루트에서 특정 정점까지의 경로에서 C_i >= T인 정점들 중 A_i + B_i*T의 최솟값을 각 질의마다 구한다.
어려움9트리분할 정복세그먼트 트리이분 탐색아직 제출이 없습니다시간 제한3초메모리 제한1024 MBYou are given a tree with N vertices and N−1 edges. Vertex 1 is the root of the tree. Every vertex is associated with three positive integers A_i,B_i,C_i, where C_1=109 and B_parent(x)≤B_x for all x=1, where parent(x) is the parent node of x.
If you see a tree with numbers, you naturally want to ask some queries. For each query, you are given a vertex V and number T. Then, you should find a minimum value of A_i+B_i×T, for all vertex i which lies in some shortest path between vertex 1 and V, and which satisfies C_i≥T. Note that, if T≤109, then there exists a minimum value.
In the first line, two integers N,Q are given. (1≤N≤80000,1≤Q≤160000).
In the next line, N integers A_1,A_2,⋯,A_N are given. (1≤A_i≤109)
In the next line, N integers B_1,B_2,⋯,B_N are given. (1≤B_i≤109)
In the next line, N integers C_1,C_2,⋯,C_N are given. (1≤C_i≤109)
In the next N−1 lines, two integers X,Y denoting the endpoints of edges are given. (1≤X,Y≤N)
In the next Q lines, two integers V,T denoting the arguments of queries are given. (1≤V≤N,0≤T≤109)
It is guaranteed that C_1=109, and B_parent(x)≤B_x for all x=1, when parent(x) is the parent node of x.
Print Q lines. In each line, print a single integer which is the minimum value asked by the given query.