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;
int n,m,height[200200], dp[200200], p;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m;
for(int i = 1; i<=n; ++i){
cin >> height[i];
height[i] = -(height[i] - m*i);
}
for(int i=1; i<=n; i++){
if(height[i] < 0) continue;
int idx = upper_bound(dp, dp+p, height[i]) - dp;
if(idx == p) p++;
dp[idx] = height[i];
}
cout << n - p;
}
# | 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... |