#include <bits/stdc++.h>
#define ii pair <int, int>
#define ll long long
#define llll pair <ll, ll>
#define ld long double
#define ull unsigned long long
#define el "\n"
#define sp " "
#define fi first
#define se second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define __lcm(a, b) (a / __gcd(a, b) * b)
#define sq(x) (x) * (x)
#define sqr(x) sqrtl(x)
#define cbr(x) cbrtl(x)
#define sz(a) (ll)(a.size())
using namespace std;
const ld PI = acos(-1); const int INFI = 1e9 + 7; const ll INFL = 2e18 + 7;
int n, pos, ans;
ll m, x, a[200005], b[200005];
void Solve()
{
cin >> n >> m;
for (ll i = 1; i <= n; i++)
{
cin >> x;
a[i] = i * m - x;
b[i] = INFL;
}
for (int i = 1; i <= n; i++)
{
if (a[i] > 0)
{
pos = upper_bound(b + 1, b + 1 + n, a[i]) - b;
b[pos] = a[i];
ans = max(ans, pos);
}
}
cout << n - ans;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
Solve();
return 0;
}
//coded by icyalmond
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |