https://codeforces.com/contest/1028/problem/D

这里先讲2个知识点吧:

1.set,map都有序容器自定义结构体的方法:‘

          方法1:

struct node {
	int a, b;
	bool operator<(node c)const
	{
		if(a!=c.a)return a<c.a;
        else return b<c.b
	}
};
set<node>S;

有一个一定要注意到的地方,就是<操作符后面的const

          方法2:

struct node {
	int a, b;
};
struct cmp
{
	bool operator()(node le,node ri)const
	{
		if (le.a != ri.a)return le.a < ri.a;
		else return le.b < ri.b;
	}
};
set<node,cmp>S;

2.sort函数,lower_bound函数在不同容器中的区别

sort函数其实没啥好说的,线性容器O(nlogn),非线性容器不sort

lower_bound的话这里有个坑,就是lower_bound在线性容器里复杂度是O(logn)但非线性容器里是O(n),于是乎,会有同学在set里面使用lower_bound,所以就像我一样T了