제출 #1164759

#제출 시각아이디문제언어결과실행 시간메모리
1164759Ghulam_JunaidRabbit Carrot (LMIO19_triusis)C++20
14 / 100
52 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    ll dp[n + 5] = {};
    for (ll i = 1; i <= n; i ++){
        ll x;
        cin >> x;

        ll ind = -1;
        for (ll j = ans; j <= n; j ++){
            if (dp[j] + m >= x){
                ind = j;
                break;
            }
        }

        for (ll j = ans + 1; j <= n; j ++)
            dp[j] = dp[j - 1] + m;
        if (ind == ans) dp[ind] = x;
        else{
            dp[ind] = max(dp[ind], x);
            ans++;
        }
    }
    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...