快读出问题了orz
查看原帖
快读出问题了orz
594257
sad_desert楼主2022/6/2 22:39
#include<bits/stdc++.h>
using namespace std;
long long j,i,n,m1,m2,ans,temp,q[100010],k,lll,ppp;
//m1国内 m2国际 
struct kr{
	long long st;
	long long la;
}a[100010],b[100010];
bool cmp(kr x,kr y){
	return x.st <y.st ;
}
long long maxn(long long x,long long y){
	if(x>y)return x;
	else if(x<y)return y;
}
inline long long redn(long long& ret) {
    ret=0;
	int f=1;
	char ch=getchar();
    while (ch<'0'||ch>'9'){
		if (ch=='-') 
			f=-f;
		ch=getchar();
	}
    while (ch>='0'&&ch<='9') 
		ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();
    ret*=f;
}
int main(){
	cin>>n>>m1>>m2;
	for(i=0;i<m1;++i){
		redn(a[i].st);
		redn(a[i].la); 
	}
	for(i=0;i<m2;++i){
		redn(b[i].st);
		redn(b[i].la);
	}
	if(n>=m1+m2){
		cout<<m1+m2;
		return 0;
	}//管够情况下 
	sort(a,a+m1,cmp);
	sort(b,b+m2,cmp);
	long long fi=maxn(0,n-m2),wei=min(n,m2);
	for(i=fi;i<wei;++i){
		temp=n,j=n-i;
		for(k=0;k<i;++k)
			q[k]=a[k].la;
		for(k=i;k<m1;++k){
			for(lll=0;lll<i;++lll){
				if(q[lll]<=a[k].st){
					++temp,q[lll]=a[k].la;
					break;
				}
			}
		}
		for(k=i;k<n;++k)
			q[k]=b[k-i].la;
		for(k=j;k<m2;++k){
			for(lll=i;lll<n;++lll){
				if(q[lll]<=b[k].st){
					++temp,q[lll]=b[k].la;
					break;
				}
			}
		}
		if(temp>ans)
			ans=temp;
	}
	cout<<ans;
	return 0;
}
  

cin45快读REQwQ

2022/6/2 22:39
加载中...