Submission #1217681

#TimeUsernameProblemLanguageResultExecution timeMemory
1217681muhammadali_2009Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
21 ms8124 KiB
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+     //

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long
#define int long long
#define all(x) x.begin(), x.end()
#define all1(x) x.rbegin(), x.rend()
#define seea(x) for(int i = 0; i < x; i++)
#define pb push_back
#define ff first
#define vc vector
#define ss second

using namespace std;  
const int mod = 1e9 + 7;
const int MOD = 998244353;

int lnds(vector<int>a){
    vector<int>dp;
    for(int i = 0; i < a.size(); i ++){
        auto id = upper_bound(dp.begin(), dp.end(), a[i]);
        if(id == dp.end()){
            dp.push_back(a[i]);
        }
        else dp[id - dp.begin()] = a[i];
    }
    return dp.size();
}

void solve(){
    int n, mx; cin >> n >> mx;
    vector<int>a(n);
    seea(n)cin >> a[i];
    vector<int>nw;
    for(int i = 1; i <= n; i ++){
        if(i * mx >= a[i - 1]){
            nw.push_back(i * mx - a[i - 1]);
        }
    }
    cout << n - lnds(nw);
}

signed main(){
    fast;
    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...