题目:Charging | JXNUOJ
描述:
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).
Xxy 是 宇宙的王。为了抵抗入侵者,他订购了许多太空战舰。现在他准备为他的太空飞船充电。
他有N个太空飞船。这N个飞船被从1到N命名并且按顺序排好。
Xxy有M个充电计划。第i个计划由两个正整数构成,li和ri。意思是在这个计划中他会替编号从li到ri的飞船充电。
Xxy会选择其中一些计划。如果他一共选择了tot个计划,x是每个计划中要充电的船的数量。Xxy想要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)
第一行包括两个正整数N和M(N,M≤300000)。
接下来的M行,每行包括两个正整数li和ri。(li≤ri)
输出:
The output contains a positive integer. The maximal value of min(tot,x).
输出包括一个正整数,即min(tot,x)中的最大值。