3133.Jzzhu and Cities

Time Limit: 1s Memory Limit: 256MB

Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One can use the i-th train route to go from capital of the country to city si (and vise versa), the length of this route is yi.

Jzzhu doesn't want to waste the money of the country, so he is going to close some of the train routes. Please tell Jzzhu the maximum number of the train routes which can be closed under the following condition: the length of the shortest path from every city to the capital mustn't change.

Input Format(From the terminal/stdin)

The first line contains three integers n,m,k (2 \le n \le 105;1 \le m \le 3 \cdot 105;1 \le k \le 105).

Each of the next m lines contains three integers ui,vi,xi (1 \le ui,vi \le n;ui \neq vi;1 \le xi \le 109).

Each of the next k lines contains two integers si and yi (2 \le si \le n;1 \le yi \le 109).

It is guaranteed that there is at least one way from every city to the capital. Note, that there can be multiple roads between two cities. Also, there can be multiple routes going to the same city from the capital.

Output Format(To the terminal/stdout)

Output a single integer representing the maximum number of the train routes which can be closed.

Sample Input 1

Copy
5 5 3
1 2 1
2 3 2
1 3 3
3 4 4
1 5 5
3 5
4 5
5 5
 · · \n
 · · \n
 · · \n
 · · \n
 · · \n
 · · \n
 · \n
 · \n
 · \n

Sample Output 1

Copy
2
 \n

Sample Input 2

Copy
2 2 3
1 2 2
2 1 3
2 1
2 2
2 3
 · · \n
 · · \n
 · · \n
 · \n
 · \n
 · \n

Sample Output 2

Copy
2
 \n

Submit

请先 登录

© 2025 FAQs