Submission #7576

# Submission time Handle Problem Language Result Execution time Memory
7576 2014-08-11T12:44:54 Z dohyun0324 배열 탈출 (GA8_array) C++
0 / 100
0 ms 49908 KB
#include<stdio.h>
int n,a[2500][2500],d[2500][2500];
int mini(int x,int y)
{
    if(x<y) return x;
    return y;
}
int f(int x)
{
    if(x>0) return x;
    return 0;
}
int main()
{
    int i,j;
    freopen("input.txt","r",stdin);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
        {
            if(i==0 || j==0) d[i][j]=2100000000;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i==1 && j==1) continue;
            d[i][j]=mini(d[i-1][j]+f(a[i][j]-a[i-1][j]+1),d[i][j-1]+f(a[i][j]-a[i][j-1]+1));
        }
    }
    printf("%d",d[n][n]);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 49908 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 49908 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 49908 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 49908 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -