#130. islands
islands
Description
有编号1到N的N座小岛,N-1座桥连接着它们,第i座桥连接编号为i和i+1的岛,某一天若干岛之间发生了争执,岛民向你提出了M条要求,每个要求都是一对岛的编号,要求是通过摧毁某些桥梁使得这两个编号的岛之间不能通过桥梁互通,请用最小的代价满足所有要求(即破坏最少数量的岛)。
Format
Input
N M
a1 b1
a2 b2
:
aM bM
没有相同的要求
Output
One integer, the sum of x and y.
Samples
5 2
1 4
2 5
1
破坏2号桥梁即可满足
Limitation
1s, 1024KiB for each test case.