답안 #799444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799444 2023-07-31T14:34:19 Z anton Safety (NOI18_safety) C++17
7 / 100
7 ms 2260 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
const int INF = 1e18;
const int MAX_N = 500;
const int MAX_H = 500;
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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 276 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 276 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 7 ms 2260 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 276 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 7 ms 2260 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 276 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 7 ms 2260 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 276 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 0 ms 340 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 276 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 0 ms 340 KB Output isn't correct
14 Halted 0 ms 0 KB -