/**
* author: MINHTPC
*
**/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin() , a.end()
#define FOR(i ,a , b) for(int i = a ; i <= b ; ++i)
#define bit(mask,i) ((mask>>i)&1)
#define name "task"
#define lo lower_bound
#define up upper_bound
#define count_bit1(x) __builtin_popcountll(x)
#define count_bit01(x) __builtin_clzll(x)
#define count_bit10(x) __builtin_ctzll(x)
using namespace std;
const int N=2e5+5;
long long a[N],e[N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n,MAX;
cin >> n >> MAX;
int m=0;
for(int i=1;i<=n;i++) cin >> a[i];
for(int i=1;i<=n;i++) {
if(a[i]<=MAX*i) {
e[++m]=MAX*i-a[i];
}
}
vector<ll>res;
for(int i=1;i<=m;i++) {
auto it=upper_bound(all(res),e[i]);
if(it==res.end()) res.push_back(e[i]);
else *it=e[i];
}
cout << n-res.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... |