Submission #760441

# Submission time Handle Problem Language Result Execution time Memory
760441 2023-06-17T14:58:27 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=min(dp[i-1][j-1]+k, 1000000000);
            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 0 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 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 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 0 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 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 31 ms 64492 KB Output is correct
21 Correct 40 ms 98176 KB Output is correct
22 Correct 80 ms 98132 KB Output is correct
23 Correct 52 ms 98128 KB Output is correct
24 Correct 44 ms 98184 KB Output is correct
25 Correct 60 ms 98248 KB Output is correct
26 Correct 47 ms 98096 KB Output is correct
27 Correct 78 ms 98204 KB Output is correct
28 Correct 44 ms 98180 KB Output is correct
29 Correct 43 ms 98124 KB Output is correct
30 Correct 59 ms 98204 KB Output is correct
31 Correct 81 ms 98160 KB Output is correct
32 Correct 65 ms 98088 KB Output is correct
33 Correct 68 ms 98196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 31 ms 64492 KB Output is correct
5 Correct 40 ms 98176 KB Output is correct
6 Correct 80 ms 98132 KB Output is correct
7 Correct 52 ms 98128 KB Output is correct
8 Correct 44 ms 98184 KB Output is correct
9 Correct 60 ms 98248 KB Output is correct
10 Correct 47 ms 98096 KB Output is correct
11 Correct 78 ms 98204 KB Output is correct
12 Correct 44 ms 98180 KB Output is correct
13 Correct 43 ms 98124 KB Output is correct
14 Correct 59 ms 98204 KB Output is correct
15 Correct 81 ms 98160 KB Output is correct
16 Correct 65 ms 98088 KB Output is correct
17 Correct 68 ms 98196 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 0 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 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 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 1 ms 212 KB Output is correct
34 Correct 83 ms 98204 KB Output is correct
35 Correct 83 ms 98208 KB Output is correct
36 Correct 83 ms 98204 KB Output is correct
37 Correct 45 ms 98144 KB Output is correct
38 Correct 81 ms 98152 KB Output is correct
39 Correct 45 ms 98132 KB Output is correct
40 Correct 81 ms 98212 KB Output is correct
41 Correct 82 ms 98132 KB Output is correct
42 Correct 65 ms 98184 KB Output is correct
43 Correct 64 ms 98188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 98204 KB Output is correct
2 Correct 83 ms 98208 KB Output is correct
3 Correct 83 ms 98204 KB Output is correct
4 Correct 45 ms 98144 KB Output is correct
5 Correct 81 ms 98152 KB Output is correct
6 Correct 45 ms 98132 KB Output is correct
7 Correct 81 ms 98212 KB Output is correct
8 Correct 82 ms 98132 KB Output is correct
9 Correct 65 ms 98184 KB Output is correct
10 Correct 64 ms 98188 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 31 ms 64492 KB Output is correct
15 Correct 40 ms 98176 KB Output is correct
16 Correct 80 ms 98132 KB Output is correct
17 Correct 52 ms 98128 KB Output is correct
18 Correct 44 ms 98184 KB Output is correct
19 Correct 60 ms 98248 KB Output is correct
20 Correct 47 ms 98096 KB Output is correct
21 Correct 78 ms 98204 KB Output is correct
22 Correct 44 ms 98180 KB Output is correct
23 Correct 43 ms 98124 KB Output is correct
24 Correct 59 ms 98204 KB Output is correct
25 Correct 81 ms 98160 KB Output is correct
26 Correct 65 ms 98088 KB Output is correct
27 Correct 68 ms 98196 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 0 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 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Runtime error 98 ms 262144 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -