#include<cstdio>
#include<algorithm>
#include<memory.h>
#define INF 1e18
using namespace std;
int n;
int a[3000][3000];
long long d[3000][3000];
long long f(int x,int y){
if(x>=n||y>=n)return INF;
if(x==n-1&&y==n-1)return 0;
long long& ret=d[x][y];
if(ret!=-1)return ret;
ret=min(f(x+1,y)+max(a[x+1][y]-a[x][y]+1,0),f(x,y+1)+max(a[x][y+1]-a[x][y]+1,0));
return ret;
}
int main(){
scanf("%d",&n);
memset(d,-1,sizeof(d));
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("%lld",f(0,0));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |