#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
ll a[n];
for(int i=0;i<n;i++){
cin>>a[i];
a[i]=m*(i+1)-a[i];
}
vector<ll> d(n+1,1000000000000000001);
d[0]=0;
int ans=0;
for(int i=0;i<n;i++){
if(a[i]){
int j=upper_bound(d.begin(),d.end(),a[i])-d.begin();
if(d[j-1]<=a[i]&&a[i]<=d[j]){
d[j]=a[i];
ans=max(j,ans);
}
}
}
cout<<n-ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |