제출 #1284368

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

#define pb push_back                    
#define ll long long 
#define s second
#define pb push_back
#define f first
#define int long long
#define s second
const long long inf = 2e9 + 7;
const int N = 4e5 + 101;

void solve(){     
    int n,m;
    cin >> n >> m;
    int a[n + 1];
    a[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector <int> dp(n + 1,-inf);
    dp[0] = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < i; j++){
            if(dp[j] < 0) continue;
            if(a[j] >= a[i] || (i - j) * m >= (a[i] - a[j])){
                if(dp[i] < dp[j] + 1){
                    dp[i] = dp[j] + 1;
                }
            }
        }
    }
    int mx = 0;
    for(int i = 0; i <= n; i++) mx = max(mx, dp[i]);
    cout << n - mx;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("promote.in", "r", stdin);
    //freopen("promote.out", "w", stdout);
    int t = 1;
    while(t--){
     	solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...