Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define PB push_back
- #define F first
- #define S second
- typedef long long LL;
- using namespace std;
- const int MOD = 1e9+7;
- const int SIZE = 2001;
- vector<pair<int,int> > pp;
- int dp[SIZE];
- int main(){
- int n,d;
- scanf("%d%d",&n,&d);
- pp.PB(make_pair(0,0));
- for(int i=0;i<n;i++){
- int x,y;
- scanf("%d%d",&x,&y);
- pp.PB(make_pair(y,x));
- }
- sort(pp.begin(),pp.end());
- memset(dp,-1,sizeof(dp));
- dp[0]=0;
- int an=0;
- for(int i=1;i<=n;i++){
- for(int j=0;j<i;j++){
- if(dp[j]==-1)continue;
- if(abs(pp[i].S-pp[j].S)<=d*(LL)(pp[i].F-pp[j].F)){
- dp[i]=max(dp[i],dp[j]+1);
- }
- }
- an=max(an,dp[i]);
- }
- printf("%d\n",an);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment