91分WA test 4求助
查看原帖
91分WA test 4求助
712647
rhx103513yyds楼主2024/7/19 10:39
#include<bits/stdc++.h>
//#pragma GCC optimize(3)
using namespace std;
#define int long long
int n;
struct node{
	int l,w;
}a[5005];
bool c1(node a,node b){
	if(a.l==b.l)return a.w>b.w;
	return a.l>b.l;
}
bool c2(node a,node b){
	if(a.w==b.w)return a.l>b.l;
	return a.w>b.w;
}
int f[5005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].l>>a[i].w;
	int a1=0,a2=0;
	sort(a+1,a+1+n,c1);
	a2=1;
	f[a1]=a[a1].w;
	for(int i=2;i<=n;i++){
		if(a[i].w>f[a1])f[++a1]=a[i].w;
		else{
			int p=lower_bound(f+1,f+1+a1,a[i].w)-f;
			f[p]=a[i].w;
		}
	}
	sort(a+1,a+1+n,c2);
	a2=1;
	f[a2]=a[a2].l;
	for(int i=2;i<=n;i++){
		if(a[i].l>f[a2])f[++a2]=a[i].l;
		else{
			int p=lower_bound(f+1,f+1+a2,a[i].l)-f;
			f[p]=a[i].l;
		}
	}
	int ans=max(1LL,min(a1,a2));
	cout<<ans;
//	cout<<a1<<" "<<a2;
	return 0;
}

/*
100
5436 7946 
1350 3080 
6245 3855 
3909 5194 
1257 4648 
3688 5327 
6101 5645 
5921 1493 
5758 6463 
4909 1696 
4405 7934 
3528 4635 
2079 471 
1088 281 
1258 7404 
1610 3838 
2362 5294 
6553 3472 
2415 7632 
3596 3776 
3074 4059 
6481 6051 
2482 705 
6486 2352 
2082 6662 
3236 4270 
854 4917 
985 6312 
4291 4248 
4638 4670 
6395 7345 
7176 2863 
5249 5926 
5491 5346 
2646 6287 
4743 375 
2373 5077 
4748 5972 
3862 6803 
6494 3737 
3378 6192 
7388 7894 
6386 3634 
1759 7732 
7394 5450 
866 712 
4294 2344 
4906 7958 
4789 4410 
7904 4556 
18 7177 
5109 6407 
6644 1805 
544 5134 
1017 2720 
7285 438 
7134 773 
1875 3289 
4042 2538 
4036 3745 
1845 7912 
224 7018 
2722 7710 
4972 6329 
7090 2151 
5622 5291 
1563 7632 
1721 33 
3957 4620 
4532 3781 
2639 6974 
2420 7918 
5602 6746 
6485 231 
6664 4155 
6589 5878 
5624 578 
3875 6369 
5721 3607 
4677 2006 
3298 4282 
4328 4793 
6035 5725 
4177 2384 
361 3599 
1451 677 
3848 6500 
5606 6951 
116 2837 
453 369 
4203 6619 
4399 4659 
2236 1462 
5185 3076 
2615 5730 
908 4651 
4435 2010 
3787 2941 
2260 5869 
7163 1104

18

*/

2024/7/19 10:39
加载中...