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;
const int Nmax = 2e5;
const int MOD = 1000000007;
int n, m, dp[Nmax + 3];
vector<int> b;
void in(){
cin >> n >> m;
for(int i = 1; i <= n; i++) {
int x; cin >> x;
int y = m * i - x;
if(y >= 0) b.push_back(y);
}
}
void sol(){
memset(dp, 0x3f, sizeof dp);
int ans = 0;
for(auto i : b){
int k = upper_bound(dp + 1, dp + n + 1, i) - (dp);
ans = max(ans, k);
dp[k] = i;
}
cout << n - ans;
}
int main(){
//freopen(" ", "r", stdin);
//freopen(" ", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
in();
sol();
}
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... |