This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3F3F3F3F3F3F3F3F
const int MXN = 3e5 + 5;
void _()
{
int n, m;
cin >> n >> m;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i], a[i] -= (i + 1) * m;
vector<int> v;
for (int i = 0; i < n; i++)
{
if (a[i] > 0) continue;
a[i] = -a[i];
if (v.empty() || v.back() <= a[i]) v.push_back(a[i]);
else v[upper_bound(v.begin(), v.end(), a[i]) - v.begin()] = a[i];
}
cout << n - (int)v.size() << '\n';
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
for (int tt = 1; tt <= t; tt++)
{
_();
}
}
# | 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... |