# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56375 | leejseo | 배열 탈출 (GA8_array) | C++98 | 788 ms | 66560 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>
#define INF 1000000000
using namespace std;
int A[2223][2223], CUR[2223], BF[2223], 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(){
for (int i=0; i<=N; i++){
BF[i] = INF;
}
for (int i=1; i<=N; i++){
CUR[0] = INF;
for (int j=1; j<=N; j++){
if (i + j == 2){
CUR[1] = 0;
BF[1] = 0;
continue;
}
CUR[j] = min(BF[j] + (A[i-1][j] > A[i][j]? 0 : A[i][j] - A[i-1][j] + 1), CUR[j-1] + (A[i][j-1] > A[i][j]? 0 : A[i][j] - A[i][j-1] + 1));
BF[j] = CUR[j];
}
}
}
int main(void){
input();
DP();
printf("%d\n", CUR[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... |