#K46002. Minimum Pipeline Changes
Minimum Pipeline Changes
Minimum Pipeline Changes
This problem involves a city's water pipeline system which is represented as an undirected graph. The city is divided into N sections, and there are M pipelines connecting some pairs of these sections. Each section i has a water demand di. In order to meet all water demands, a pipeline change must be made in every section that demands water.
Your task is to determine the minimum number of pipeline changes required. Under the simplified assumption, the answer is equal to the number of sections with a positive water demand, i.e., $$ answer = \sum_{i=1}^{N} [d_i > 0] $$
The input provides the number of sections and pipelines, the list of pipeline connections, and the water demand in each section. You should output a single integer representing the required number of pipeline changes.
inputFormat
The first line contains two integers N and M separated by a space.
The following M lines each contain two integers u and v, representing a pipeline between section u and section v.
The last line contains N integers representing the water demands d1, d2, ..., dN for each section.
Input is provided via standard input (stdin).
outputFormat
Output a single integer which is the minimum number of pipeline changes required. The result should be printed to standard output (stdout).
## sample5 6
1 2
1 3
2 4
2 5
3 4
3 5
10 20 30 40 50
5