把所有人按 $a_i$ 从小到大排序, $a_i$ 越小说明如果那个人说真话,分数越高
对于 $a_i$ 相同的人,如果 $b_i$ 不同那么最多只有一种 $b_i$ 是真的,所以考虑把 $a_i,b_i$ 相同的合并,价值为人数
进一步考虑,对于 $a_i$ 不同的人,他们同时说真话的条件是什么
不妨把这些人看成一个个区间,$a_i,b_i$ 的人所在的区间为 $[a_i+1,n-b_i]$,即在这一个区间的人分数要一样,如果两个不同的区间要同时合法,那么因为他们分数不同,所以两个区间不能有交集
现在题目就转化成了:若干个区间,每个区间有一个价值,取出若干不交的区间使得价值最大
然后按右端点排序,直接 $dp$ 即可
#include#include #include #include #include using namespace std;typedef long long ll;inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f;}const int N=2e5+7;int n,m;struct dat { int l,r,v; inline bool operator < (const dat &tmp) const { return l!=tmp.l ? l