题目:
Charging
1000ms 131072K
描述:
Xxy is the king of the universe. In order to resist the invasion, he ordered the construction of many space warships.Now,he wants to charge his space ships.
He has N space ships.The N ships are numbered from 1 to N and lined up in order.
Xxy has M charging plans.The i-th plan is describe by two positive integers li,ri.It means in this plan, he will charge the ships numbered from li to ri.
Xxy will choose some of these plan.If he totally choose tot plans,x is the number of ships that charged in every plans.Xxy want to maximize the value of min(tot,x).
输入:
The first line contains two positive integers N and M(N,M≤300000)。
The next M lines,each containing two positive integers li and ri.(li≤ri)
输出:
The output contains a positive integer. The maximal value of min(tot,x).
样例输入:
3 3
1 3
2 2
1 2
样例输出:
2
翻译:
描述:
Xxy是宇宙的国王,为了抵抗入侵者,他命令修建一些太空军舰,他想为他的太空船充电。
他有N艘太空船,N艘船按1到N的顺序排列。
Xxy 有M个充电的计划,第i个计划用两个正整数描述,意味着在这个计划里,他将给从数字li 到ri的太空船充电.
Xxy将选择一些计划,如果他完全选择 tot计划,X是在每个计划中收费的太空船的数量, Xxy想最大化 min(tot,x)的价值。
输入:
第一行包含两个正整数N 和 M(N,M≤300000)。
接下来的M行,每一行包含两个正整数li and ri.(li≤ri)。
输出:
输出包含一个正整数,min(tot,x)的最大价值。