atcoder#ABC166C. [ABC166C] Peaks
[ABC166C] Peaks
Score : points
Problem Statement
There are observatories in AtCoder Hill, called Obs. , Obs. , , Obs. . The elevation of Obs. is . There are also roads, each connecting two different observatories. Road connects Obs. and Obs. .
Obs. is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. using just one road. Note that Obs. is also good when no observatory can be reached from Obs. using just one road.
How many good observatories are there?
Constraints
- Multiple roads may connect the same pair of observatories.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of good observatories.
4 3
1 2 3 4
1 3
2 3
2 4
2
- From Obs. , you can reach Obs. using just one road. The elevation of Obs. is not higher than that of Obs. , so Obs. is not good.
- From Obs. , you can reach Obs. and using just one road. The elevation of Obs. is not higher than that of Obs. , so Obs. is not good.
- From Obs. , you can reach Obs. and using just one road. The elevation of Obs. is higher than those of Obs. and , so Obs. is good.
- From Obs. , you can reach Obs. using just one road. The elevation of Obs. is higher than that of Obs. , so Obs. is good.
Thus, the good observatories are Obs. and , so there are two good observatories.
6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6
3