Cow Jog G

題目鏈接:Cow Jog G


顯然我們只和第一個位置,和最後的位置有關。速度其實無所謂。

然後就變成一個一個序列的最少LIS劃分數,根據dirworth定理,也就是最長反鏈。


AC代碼:

#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,t,a[N],d[N],cnt;
signed main(){
	cin>>n>>t;
	for(int i=1,b,c;i<=n;i++)	scanf("%lld %lld",&b,&c),a[i]=b+c*t;
	for(int i=n;i>=1;i--){
		if(!cnt||a[i]>=d[cnt])	d[++cnt]=a[i];
		else	d[upper_bound(d+1,d+1+cnt,a[i])-d]=a[i];
	}
	cout<<cnt;
	return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章