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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll mod = (ll)1e9+7;
void solve(){
int n,m; cin>>n>>m;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
a[i]-=(i+1)*m;
}
reverse(a.begin(),a.end());
vector<int> lis;
for(auto ai:a){
int pos=upper_bound(lis.begin(),lis.end(),ai)-lis.begin();
if(pos==(int)lis.size()) lis.push_back(ai);
else lis[pos]=ai;
}
cout<<n-(upper_bound(lis.begin(),lis.end(),0)-lis.begin())<<"\n";
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int T=1; //cin>>T;
while(T--) solve();
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... |