#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
long long a[n+1];
a[0]=0;
for(int i=1; i<=n; i++)
{
cin >> a[i];
a[i]-=m*i;
}
vector<long long> dp(n+3, INT64_MAX);
dp[0]=INT64_MIN;
for(int i=n; i>=0; i--)
{
if(a[i]>0)continue;
int id = upper_bound(dp.begin(), dp.end(), a[i])-dp.begin();
dp[id]=a[i];
}
for(int i=1; i<dp.size(); i++)
{
if(dp[i]==INT64_MAX)
{
cout << n-i+2;
return 0;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |