玄关求条 71pts
查看原帖
玄关求条 71pts
1461393
weapons楼主2025/8/4 11:52
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+5;
struct Ele{
	int x,y;
}ele[N];
bool cmp(Ele aa,Ele bb){
	return aa.x<=bb.x;
}
int n,t[N],a[N],li[N],len,k;
signed main() {
	cin>>n>>k;
	for(int i=1;i<=k;i++)cin>>t[i];
	for(int i=1;i<=k;i++)cin>>a[i];
	for(int i=1;i<=k;i++){
		ele[i].x=t[i]+a[i];
		ele[i].y=t[i]-a[i];
	}
	sort(ele+1,ele+k+1,cmp);
	for(int i=k;i>=1;i--){
		if(len==0){
			li[1]=ele[k].y;
			len=1;
		}
		else{
			int maxn=lower_bound(li+1,li+len+1,ele[i].y)-li;
			li[maxn]=ele[i].y;
			len=max(len,maxn);
		}
	}
	cout<<len;
}
2025/8/4 11:52
加载中...