## Selective Selective Cutting

View as PDF

Points: 20
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

I have a bidirectional unweighted connected graph with nodes, numbered from to , each with a value .

There are exactly edges. The edge connects and . There is at most one edge between any pair of nodes. No edge connects a node with itself.

questions are asked in the form: "On the path from to , including these and themselves, how many nodes have a value of at least ?".

#### Constraints

All numbers in the input are positive integers.

#### Input Specifications

All numbers on the same line of input are separated by spaces.

The first line of input contains numbers: and .

The second line of input contains numbers, the number is .

The next lines each contain numbers: and .

The next lines contain numbers: , , and .

#### Output Specification

lines each containing one number, the line representing the answer to the question.

#### Sample Input 1

5 2
10 20 30 40 50
1 2
1 3
2 4
2 5
3 4 20
4 5 30

#### Sample Output 1

3
2

#### Explanation for Sample 1

The path from to is . Out of these trees, of them have a height of at least .

The path from to is . Out of these trees, of them have a height of at least .

## Comments

There are no comments at the moment.