Submission #299415

#TimeUsernameProblemLanguageResultExecution timeMemory
299415BruteforcemanRabbit Carrot (LMIO19_triusis)C++11
63 / 100
1051 ms1788 KiB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 1e8;
int a[maxn], dp[maxn];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  dp[0] = 0; 
  for(int i = 1; i <= n; i++) {
    dp[i] = -inf;
    for(int j = 0; j < i; j++) {
      if(a[i] - a[j] <= 1LL * k * (i - j)) {
        dp[i] = max(dp[i], 1 + dp[j]);
      }
    }
    ans = max(ans, dp[i]);
  }
  cout << n - ans << endl;
  return 0;
}

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |   scanf("%d %d", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~
triusis.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     scanf("%d", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...