제출 #895136

#제출 시각아이디문제언어결과실행 시간메모리
895136vjudge1Rabbit Carrot (LMIO19_triusis)C++17
63 / 100
33 ms98424 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

const int N = 5e3+3, inf = INT_MAX;

int n, m, mx, a[N], dp[N][N];
// dp[i][j] = altura maxima que puedes conseguir en la plataforma i con j movimientos

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> m;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      int x = -inf;
      if (dp[i-1][j] + m >= a[i]) x = max(x, a[i]);
      if (j && dp[i-1][j-1] != -inf) x = max(x, dp[i-1][j-1] + m);
      dp[i][j] = x;
    }
  }

  int ans = inf;
  for (int i = 0; i <= n; i++) {
    if (dp[n][i] != -inf) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...