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;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
int n,m;
cin>>n>>m;
int a[n+5],b[n+5];
for(int i=1;i<=n;i++){
cin>>a[i];
b[i]=i*m-a[i];
}
vector<int>v;
for(int i=1;i<=n;i++){
if(b[i]<0) continue;
if(v.empty()||v.back()<=b[i]){
v.pb(b[i]);
}
else{
int pos=upper_bound(all(v),b[i])-v.begin();
v[pos]=b[i];
}
}
cout<<n-v.size();
}
# | 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... |