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>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
vector <int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
a[i]-=(i+1)*m;
}
reverse(all(a));
vector <int> v(n+1,1e18);
v[0]=-1e18;
for(int i=0;i<n;i++){
auto pos=upper_bound(all(v),a[i])-v.begin();
v[pos]=a[i];
}
auto pos=upper_bound(all(v),0ll)-v.begin();
cout<<n+1-pos<<"\n";
}
/*
5 400
300
700
200
1000
500
3 300
700
1000
1300
*/
# | 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... |