Submission #1040648

#TimeUsernameProblemLanguageResultExecution timeMemory
1040648lmaobruhRabbit Carrot (LMIO19_triusis)C++14
63 / 100
1041 ms2896 KiB
// 027 072 207 270 702 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define fo(i, a, b) for (int i = (a), b_ = (b); i <= b_; ++i)
#define fod(i, a, b) for (int i = (a), b_ = (b); i >= b_; --i)
#define rep(i, n) fo(i, 1, n)
#define per(i, n) fod(i, n, 1)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
const int N = 1e6+5;

int n, m, a[N], dp[N];
bool reach[N];

void sol() {
  cin >> n >> m;
  reach[0] = 1;
  rep(i, n) {
    cin >> a[i];
    for (int j = 0; j < i; ++j)
      if (a[j] >= a[i] - m * (i - j) && reach[j])
        chmax(dp[i], dp[j]+1);
    reach[i] = (dp[i] > 0);
  }
  cout << n - *max_element(dp+1, dp+n+1);
}

signed main() {
  cin.tie(0) -> sync_with_stdio(0);
  // if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin);
  int tc = 1, test = 0; // cin >> tc;
  while (++test <= tc) sol();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...