Submission #1216282

#TimeUsernameProblemLanguageResultExecution timeMemory
1216282amaninnightRabbit Carrot (LMIO19_triusis)C++20
100 / 100
17 ms2292 KiB
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define $boost cin.tie(0) -> sync_with_stdio(0), cout.tie(0);
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<ll> VLL;

const int maxn = 2e5 + 5, mod = 1e9 + 7;

int a[maxn];

void solve(){
    int n, m;   cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] -= (i * m);
        a[i] = -a[i];
    }
    //for(int i = 1; i <= n; i++) cout << a[i];   cout << endl;
    vector<int> v;
    v.pb(0);
    for(int i = 1; i <= n; i++){
        if(a[i] >= v.back()){
            v.pb(a[i]);
        }
        else{
            int l = upper_bound(all(v), a[i]) - v.begin();
            v[l] = (l ? a[i] : v[l]);
        }
    }
    cout << n-v.size()+1 << endl; 
}


int main(){
    $boost;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...