WA 0pts 求助
  • 板块P2782 友好城市
  • 楼主So_Cat
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/7/16 10:59
  • 上次更新2023/11/3 09:34:53
查看原帖
WA 0pts 求助
881373
So_Cat楼主2023/7/16 10:59
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct city{
	int a , b ;
} a[200005] ;
int n , lis[200005] , cnt ;
bool cmp( city a , city b ){
	return a.a < b.a ;
}
signed main(){
	cin >> n ;
	for( int i = 1 ; i <= n ; i ++ ){
		cin >> a[i].a >> a[i].b ;
	}
	sort( a + 1 , a + 1 + n , cmp );
	lis[++ cnt] = a[1].b ;
	for( int i = 2 ; i <= n ; i ++ ){
		int pos = upper_bound( lis + 1 , lis + 1 + cnt , a[i].b ) - lis ;
		lis[pos] = a[i].b ;
		cnt = max( cnt , pos ) ;
	}
	cout << n - cnt ;
	return 0 ;
}

2023/7/16 10:59
加载中...