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>
#define ll long long
using namespace std;
const int mxN = (int) 2e5, mxM = 5000;
int n, m;
ll d[mxN + 1], dp[mxN + 1];
int lnds() {
dp[0] = LLONG_MIN;
fill(dp + 1, dp + 1 + n, LLONG_MAX);
for(int i = 1; i <= n; i++) {
int l = upper_bound(dp, dp + 1 + n, d[i]) - dp;
dp[l] = d[i];
}
for(int l = n; l >= 1; l--) {
if(dp[l] != LLONG_MAX) return l;
}
return 1;
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++) {
int temp; cin >> temp;
d[i] = 1ll * m * i - temp;
}
cout << n - lnds();
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... |