# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56365 | leejseo | 배열 탈출 (GA8_array) | C++98 | 759 ms | 39536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <algorithm>
using namespace std;
int A[2230][2230], D[2230][2230], N;
void input(){
scanf("%d", &N);
for (int i=1; i<=N; i++){
for (int j=1; j<=N; j++){
scanf("%d", &A[i][j]);
}
}
}
void DP(){
D[1][1] = 0;
for (int i=1; i<=N; i++){
for (int j=1; j<=N; j++){
if (i == 1 && j == 1) continue;
D[i][j] = (int)1e9;
D[i][j] = min(D[i][j], D[i-1][j] + max(0, A[i][j] - A[i-1][j] + 1));
D[i][j] = min(D[i][j], D[i][j-1] + max(0, A[i][j] - A[i][j-1] + 1));
}
}
}
int main(void){
input();
DP();
printf("%d\n", D[N][N]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |