Submission #760439

# Submission time Handle Problem Language Result Execution time Memory
760439 2023-06-17T14:55:08 Z lalig777 Rabbit Carrot (LMIO19_triusis) C++14
63 / 100
98 ms 262144 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]={0};
    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=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<<endl;
            return 0;
        }
    }return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 32 ms 64428 KB Output is correct
21 Correct 47 ms 98160 KB Output is correct
22 Correct 83 ms 98204 KB Output is correct
23 Correct 59 ms 98224 KB Output is correct
24 Correct 44 ms 98128 KB Output is correct
25 Correct 58 ms 98200 KB Output is correct
26 Correct 45 ms 98172 KB Output is correct
27 Correct 76 ms 98224 KB Output is correct
28 Correct 43 ms 98212 KB Output is correct
29 Correct 42 ms 98164 KB Output is correct
30 Correct 58 ms 98132 KB Output is correct
31 Correct 80 ms 98204 KB Output is correct
32 Correct 63 ms 98224 KB Output is correct
33 Correct 68 ms 98164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 32 ms 64428 KB Output is correct
5 Correct 47 ms 98160 KB Output is correct
6 Correct 83 ms 98204 KB Output is correct
7 Correct 59 ms 98224 KB Output is correct
8 Correct 44 ms 98128 KB Output is correct
9 Correct 58 ms 98200 KB Output is correct
10 Correct 45 ms 98172 KB Output is correct
11 Correct 76 ms 98224 KB Output is correct
12 Correct 43 ms 98212 KB Output is correct
13 Correct 42 ms 98164 KB Output is correct
14 Correct 58 ms 98132 KB Output is correct
15 Correct 80 ms 98204 KB Output is correct
16 Correct 63 ms 98224 KB Output is correct
17 Correct 68 ms 98164 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 316 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 83 ms 98144 KB Output is correct
35 Correct 83 ms 98204 KB Output is correct
36 Correct 86 ms 98256 KB Output is correct
37 Correct 43 ms 98192 KB Output is correct
38 Correct 76 ms 98124 KB Output is correct
39 Correct 44 ms 98124 KB Output is correct
40 Correct 82 ms 98232 KB Output is correct
41 Correct 81 ms 98204 KB Output is correct
42 Correct 68 ms 98496 KB Output is correct
43 Correct 64 ms 98236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 98144 KB Output is correct
2 Correct 83 ms 98204 KB Output is correct
3 Correct 86 ms 98256 KB Output is correct
4 Correct 43 ms 98192 KB Output is correct
5 Correct 76 ms 98124 KB Output is correct
6 Correct 44 ms 98124 KB Output is correct
7 Correct 82 ms 98232 KB Output is correct
8 Correct 81 ms 98204 KB Output is correct
9 Correct 68 ms 98496 KB Output is correct
10 Correct 64 ms 98236 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 32 ms 64428 KB Output is correct
15 Correct 47 ms 98160 KB Output is correct
16 Correct 83 ms 98204 KB Output is correct
17 Correct 59 ms 98224 KB Output is correct
18 Correct 44 ms 98128 KB Output is correct
19 Correct 58 ms 98200 KB Output is correct
20 Correct 45 ms 98172 KB Output is correct
21 Correct 76 ms 98224 KB Output is correct
22 Correct 43 ms 98212 KB Output is correct
23 Correct 42 ms 98164 KB Output is correct
24 Correct 58 ms 98132 KB Output is correct
25 Correct 80 ms 98204 KB Output is correct
26 Correct 63 ms 98224 KB Output is correct
27 Correct 68 ms 98164 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 316 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Runtime error 98 ms 262144 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -