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;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define pb push_back
const int N = 2e5 + 5;
int n, a[N], m;
vector<ll> b;
int solve() {
vector<ll> dp;
for (ll x: b) {
auto it = upper_bound(all(dp), x);
if (it == dp.end()) dp.pb(x);
else {
int pos = it - dp.begin();
dp[pos] = x;
}
}
return sz(dp);
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
for (int i = 1; i <= n; ++i) {
if (a[i] <= 1LL * i * m) b.pb(1LL * i * m - a[i]);
}
cout << n - solve();
}
# | 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... |