Submission #7840

# Submission time Handle Problem Language Result Execution time Memory
7840 2014-08-19T11:16:58 Z comet 배열 탈출 (GA8_array) C++
100 / 100
1004 ms 50072 KB
#include<cstdio>
#include<algorithm>
#include<memory.h>
#define INF 987654321
using namespace std;
int n;
int a[2500][2500];
int d[2500][2500];
int f(int x,int y){
    if(x>=n||y>=n)return INF;
    if(x==n-1&&y==n-1)return 0;
    int& 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("%d",f(0,0));
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 49916 KB Output is correct
2 Correct 4 ms 49916 KB Output is correct
3 Correct 12 ms 49916 KB Output is correct
4 Correct 4 ms 49916 KB Output is correct
5 Correct 0 ms 49916 KB Output is correct
6 Correct 8 ms 49916 KB Output is correct
7 Correct 4 ms 49916 KB Output is correct
8 Correct 4 ms 49916 KB Output is correct
9 Correct 8 ms 49916 KB Output is correct
10 Correct 8 ms 49916 KB Output is correct
11 Correct 8 ms 49916 KB Output is correct
12 Correct 4 ms 49916 KB Output is correct
13 Correct 8 ms 49916 KB Output is correct
14 Correct 8 ms 49916 KB Output is correct
15 Correct 0 ms 49916 KB Output is correct
16 Correct 8 ms 49916 KB Output is correct
17 Correct 8 ms 49916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 49916 KB Output is correct
2 Correct 4 ms 49916 KB Output is correct
3 Correct 8 ms 49916 KB Output is correct
4 Correct 4 ms 49916 KB Output is correct
5 Correct 8 ms 49916 KB Output is correct
6 Correct 4 ms 49916 KB Output is correct
7 Correct 4 ms 49916 KB Output is correct
8 Correct 4 ms 49916 KB Output is correct
9 Correct 4 ms 49916 KB Output is correct
10 Correct 8 ms 49916 KB Output is correct
11 Correct 8 ms 49916 KB Output is correct
12 Correct 0 ms 49916 KB Output is correct
13 Correct 12 ms 49916 KB Output is correct
14 Correct 4 ms 49916 KB Output is correct
15 Correct 8 ms 49916 KB Output is correct
16 Correct 12 ms 49916 KB Output is correct
17 Correct 0 ms 49916 KB Output is correct
18 Correct 4 ms 49916 KB Output is correct
19 Correct 4 ms 49916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 49916 KB Output is correct
2 Correct 16 ms 49916 KB Output is correct
3 Correct 24 ms 49916 KB Output is correct
4 Correct 8 ms 49916 KB Output is correct
5 Correct 8 ms 49916 KB Output is correct
6 Correct 4 ms 49916 KB Output is correct
7 Correct 16 ms 49916 KB Output is correct
8 Correct 8 ms 49916 KB Output is correct
9 Correct 12 ms 49916 KB Output is correct
10 Correct 8 ms 49916 KB Output is correct
11 Correct 16 ms 49916 KB Output is correct
12 Correct 8 ms 49916 KB Output is correct
13 Correct 8 ms 49916 KB Output is correct
14 Correct 8 ms 49916 KB Output is correct
15 Correct 12 ms 49916 KB Output is correct
16 Correct 12 ms 49916 KB Output is correct
17 Correct 4 ms 49916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1004 ms 50072 KB Output is correct
2 Correct 960 ms 50068 KB Output is correct
3 Correct 992 ms 50068 KB Output is correct
4 Correct 964 ms 50068 KB Output is correct
5 Correct 808 ms 50048 KB Output is correct
6 Correct 880 ms 50056 KB Output is correct
7 Correct 984 ms 50068 KB Output is correct
8 Correct 996 ms 50064 KB Output is correct
9 Correct 1000 ms 50064 KB Output is correct
10 Correct 964 ms 50068 KB Output is correct
11 Correct 956 ms 50068 KB Output is correct
12 Correct 960 ms 50068 KB Output is correct
13 Correct 864 ms 50052 KB Output is correct
14 Correct 952 ms 50068 KB Output is correct
15 Correct 788 ms 50040 KB Output is correct
16 Correct 964 ms 50068 KB Output is correct
17 Correct 976 ms 50072 KB Output is correct
18 Correct 884 ms 50056 KB Output is correct
19 Correct 960 ms 50072 KB Output is correct
20 Correct 960 ms 50064 KB Output is correct
21 Correct 888 ms 50056 KB Output is correct