Submission #1218131

#TimeUsernameProblemLanguageResultExecution timeMemory
1218131Born_To_LaughRabbit Carrot (LMIO19_triusis)C++17
100 / 100
18 ms2752 KiB
// Born_To_Laugh - Hughie Do
#include <bits/stdc++.h>
#define alle(sth) sth.begin(), sth.end()
using namespace std;
typedef long long ll;
[[maybe_unused]] const ll MOD = 998244353, INF = 1e9 + 7;
void solve(){
    int n, m;cin >> n >> m;
    vector<int> a(1, 0);
    for(int i=1; i<=n; ++i){
        int x;cin >> x;
        if(x > m * i)continue;
        a.push_back(m * i - x);
    }
    vector<int> dp;
    for(int i=1; i<(int)a.size(); ++i){
        int pos = upper_bound(alle(dp), a[i]) - dp.begin();
        if(pos == (int)dp.size()){
            dp.push_back(a[i]);
        }
        else{
            dp[pos] = a[i];
        }
    }
    cout << n - dp.size() << '\n';
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    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...