Submission #799445

# Submission time Handle Problem Language Result Execution time Memory
799445 2023-07-31T14:35:22 Z anton Safety (NOI18_safety) C++17
13 / 100
213 ms 2640 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
const int INF = 1e18;
const int MAX_N = 600;
const int MAX_H = 600;
int n, h;
int A[MAX_N];
int dp[MAX_N][MAX_H];
signed main(){
    cin>>n>>h;

    for(int i = 0; i<n; i++){
        cin>>A[i];
    }

    for(int i = n; i>=0; i--){
        for(int j = 0; j<MAX_H; j++){
            if(i==n){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = INF;
                for(int k = max(0LL,j-h); k<=min(MAX_H-1,j+h); k++){
                    dp[i][j] = min(dp[i][j], dp[i+1][k] + abs(k-A[i]));
                }
            }
        }
    }

    int res= INF;

    for(int i = 0; i<MAX_H; i++){
        res= min(res, dp[0][i]);
    }

    cout<<res<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 8 ms 2584 KB Output is correct
14 Correct 2 ms 2516 KB Output is correct
15 Correct 188 ms 2508 KB Output is correct
16 Correct 93 ms 2640 KB Output is correct
17 Correct 150 ms 2252 KB Output is correct
18 Correct 92 ms 1912 KB Output is correct
19 Correct 3 ms 2464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 8 ms 2584 KB Output is correct
14 Correct 2 ms 2516 KB Output is correct
15 Correct 188 ms 2508 KB Output is correct
16 Correct 93 ms 2640 KB Output is correct
17 Correct 150 ms 2252 KB Output is correct
18 Correct 92 ms 1912 KB Output is correct
19 Correct 3 ms 2464 KB Output is correct
20 Incorrect 213 ms 2388 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 8 ms 2584 KB Output is correct
14 Correct 2 ms 2516 KB Output is correct
15 Correct 188 ms 2508 KB Output is correct
16 Correct 93 ms 2640 KB Output is correct
17 Correct 150 ms 2252 KB Output is correct
18 Correct 92 ms 1912 KB Output is correct
19 Correct 3 ms 2464 KB Output is correct
20 Incorrect 213 ms 2388 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Incorrect 0 ms 340 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Incorrect 0 ms 340 KB Output isn't correct
14 Halted 0 ms 0 KB -