Submission #7327

# Submission time Handle Problem Language Result Execution time Memory
7327 2014-08-01T08:54:22 Z paulsohn 배열 탈출 (GA8_array) C
0 / 100
624 ms 65536 KB
#include<stdio.h>
int n, A[2224][2224]={0};
int cost(int r, int c){
  int h,v;
  if(r==n && c==n) return 0;
  h=(A[r][c]>A[r][c+1] ? 0 : A[r][c+1]-A[r][c]+1);
  if(r==n) return h+cost(r,c+1);
  h+=cost(r,c+1);
  v=(A[r][c]>A[r+1][c] ? 0 : A[r+1][c]-A[r][c]+1);
  if(c==n) return v+cost(r+1,c);
  v+=cost(r+1,c);
  if(h>v) return v;
  return h;
}
int main(){
  int i,j;
  scanf("%d", &n);
  for(i=1;i<=n;++i){
    for(j=1;j<=n;++j){
      scanf("%d", &A[i][j]);
    }
  }
  printf("%d\n", cost(1,1));
  return 0;
}
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 4 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 12 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 624 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -