#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{
if (ind != -1){
for (ll j = ind; j <= n; j ++)
dp[j] = max(dp[j], x);
}
ans++;
}
}
cout << ans << endl;
}
# | 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... |