Submission #7839

# Submission time Handle Problem Language Result Execution time Memory
7839 2014-08-19T11:14:52 Z comet 배열 탈출 (GA8_array) C++
0 / 100
0 ms 65536 KB
#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));
}
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -