Submission #760413

# Submission time Handle Problem Language Result Execution time Memory
760413 2023-06-17T14:41:01 Z lalig777 Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 212 KB
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
    int dp[n+1][n+1];
    int v[n];
    for (int i=0; i<n; i++){
        cin>>v[i];
        if (dp[0][i]!=-1 and v[i]-dp[0][i]<=k) dp[0][i+1]=v[i];
        else dp[0][i+1]=-1;
    }if (dp[0][n]!=-1){
        cout<<0;
        return 0;
    }for (int i=1; i<=n; i++){
        for (int j=i; j<=n; j++){
            int a=-1, b=-1;
            if (dp[i-1][j-1]!=-1) a=dp[i-1][j-1]+k;
            if (dp[i][j-1]!=-1 and v[j-1]-dp[i][j-1]<=k) b=v[j-1];
            dp[i][j]=max(a, b);
        }if (dp[i][n]!=-1){
            cout<<i;
            return 0;
        }
    }return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -