Submission #760389

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

int main(){
    int n, k; cin>>n>>k;
    vector<vector<int>>dp(n+1, vector<int>(n+1));
    vector<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<<endl;
        return 0;
    }for (int i=1; i<=n; i++){
        for (int j=1; 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[i-1]-dp[i][j-1]<=k) b=v[i-1];
            dp[i][j]=max(a, b);
        }if (dp[i][n]!=-1){
            cout<<i<<endl;
            return 0;
        }
    }return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -