Submission #760394

# Submission time Handle Problem Language Result Execution time Memory
760394 2023-06-17T14:30:50 Z lalig777 Rabbit Carrot (LMIO19_triusis) C++14
63 / 100
134 ms 262144 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[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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 300 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 272 KB Output is correct
20 Correct 23 ms 64724 KB Output is correct
21 Correct 34 ms 98372 KB Output is correct
22 Correct 127 ms 98384 KB Output is correct
23 Correct 46 ms 98384 KB Output is correct
24 Correct 46 ms 98364 KB Output is correct
25 Correct 58 ms 98392 KB Output is correct
26 Correct 38 ms 98368 KB Output is correct
27 Correct 81 ms 98380 KB Output is correct
28 Correct 39 ms 98396 KB Output is correct
29 Correct 34 ms 98260 KB Output is correct
30 Correct 57 ms 98380 KB Output is correct
31 Correct 85 ms 98384 KB Output is correct
32 Correct 64 ms 98380 KB Output is correct
33 Correct 69 ms 98384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 272 KB Output is correct
4 Correct 23 ms 64724 KB Output is correct
5 Correct 34 ms 98372 KB Output is correct
6 Correct 127 ms 98384 KB Output is correct
7 Correct 46 ms 98384 KB Output is correct
8 Correct 46 ms 98364 KB Output is correct
9 Correct 58 ms 98392 KB Output is correct
10 Correct 38 ms 98368 KB Output is correct
11 Correct 81 ms 98380 KB Output is correct
12 Correct 39 ms 98396 KB Output is correct
13 Correct 34 ms 98260 KB Output is correct
14 Correct 57 ms 98380 KB Output is correct
15 Correct 85 ms 98384 KB Output is correct
16 Correct 64 ms 98380 KB Output is correct
17 Correct 69 ms 98384 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 296 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 300 KB Output is correct
34 Correct 129 ms 98408 KB Output is correct
35 Correct 128 ms 98324 KB Output is correct
36 Correct 134 ms 98368 KB Output is correct
37 Correct 37 ms 98312 KB Output is correct
38 Correct 90 ms 98368 KB Output is correct
39 Correct 37 ms 98384 KB Output is correct
40 Correct 86 ms 98380 KB Output is correct
41 Correct 129 ms 98380 KB Output is correct
42 Correct 59 ms 98384 KB Output is correct
43 Correct 63 ms 98388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 98408 KB Output is correct
2 Correct 128 ms 98324 KB Output is correct
3 Correct 134 ms 98368 KB Output is correct
4 Correct 37 ms 98312 KB Output is correct
5 Correct 90 ms 98368 KB Output is correct
6 Correct 37 ms 98384 KB Output is correct
7 Correct 86 ms 98380 KB Output is correct
8 Correct 129 ms 98380 KB Output is correct
9 Correct 59 ms 98384 KB Output is correct
10 Correct 63 ms 98388 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 272 KB Output is correct
14 Correct 23 ms 64724 KB Output is correct
15 Correct 34 ms 98372 KB Output is correct
16 Correct 127 ms 98384 KB Output is correct
17 Correct 46 ms 98384 KB Output is correct
18 Correct 46 ms 98364 KB Output is correct
19 Correct 58 ms 98392 KB Output is correct
20 Correct 38 ms 98368 KB Output is correct
21 Correct 81 ms 98380 KB Output is correct
22 Correct 39 ms 98396 KB Output is correct
23 Correct 34 ms 98260 KB Output is correct
24 Correct 57 ms 98380 KB Output is correct
25 Correct 85 ms 98384 KB Output is correct
26 Correct 64 ms 98380 KB Output is correct
27 Correct 69 ms 98384 KB Output is correct
28 Correct 1 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 1 ms 300 KB Output is correct
33 Correct 1 ms 300 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 296 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 300 KB Output is correct
44 Runtime error 98 ms 262144 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -