2022 01.19第三天
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.
Xxy是宇宙的王。为了抵抗入侵,他下令建造了许多太空战舰。现在,他想给他的太空船充电。
He has N space ships.The N ships are numbered from 1 to N and lined up in order.
他有N艘太空船。NN船的编号从1到N,并按顺序排列。
Xxy has MM charging plans.The i-th plan is describe by two positive integers li,rili,ri.It means in this plan, he will charge the ships numbered from lili to riri.
Xxy有MM充电计划。第i个平面由两个正整数li,rili,ri描述。这意味着在这个计划中,他将负责从莉莉到里里的船只
Xxy will choose some of these plan.If he totally choose tot plans,xx is the number of ships that charged in every plans.Xxy want to maximize the value of min(tot,x)min(tot,x).
Xxy将选择其中一些计划。如果他完全选择tot计划,xx是每个计划中收费的船舶数量。Xxy想要最大化min(tot,x)min(tot,x)的值。
输入:
The first line contains two positive integers NN and M(N,M≤300000)M(N,M≤300000).
The next MM lines,each containing two positive integers lili and ri.(N,M≤300000)M(N,M≤300000).
第一行包含两个正整数NN和M.(N,M≤300000)M(N,M≤300000).
接下来的MM行,每个行包含两个正整数lili和ri。(N,M≤300000)M(N,M≤300000).
输出:
The output contains a positive integer. The maximal value of min(tot,x)min(tot,x).
输出包含一个正整数。min(tot,x)min(tot,x)的最大值。
样例输入:
3 3 1 3 2 2 1 2
样例输出:
2