# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
7344 |
2014-08-02T02:39:02 Z |
cki86201 |
배열 탈출 (GA8_array) |
C++ |
|
2000 ms |
20624 KB |
#include<stdio.h>
int n, A[2224][2224]={0};
int cost(int r, int c){
if(r>n || c>n)return 1e8;
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 |
Correct |
0 ms |
20408 KB |
Output is correct |
2 |
Correct |
0 ms |
20408 KB |
Output is correct |
3 |
Correct |
0 ms |
20408 KB |
Output is correct |
4 |
Correct |
0 ms |
20408 KB |
Output is correct |
5 |
Correct |
0 ms |
20408 KB |
Output is correct |
6 |
Correct |
0 ms |
20408 KB |
Output is correct |
7 |
Correct |
0 ms |
20408 KB |
Output is correct |
8 |
Correct |
0 ms |
20408 KB |
Output is correct |
9 |
Correct |
0 ms |
20408 KB |
Output is correct |
10 |
Correct |
0 ms |
20408 KB |
Output is correct |
11 |
Correct |
0 ms |
20408 KB |
Output is correct |
12 |
Correct |
0 ms |
20408 KB |
Output is correct |
13 |
Correct |
0 ms |
20408 KB |
Output is correct |
14 |
Correct |
0 ms |
20408 KB |
Output is correct |
15 |
Correct |
0 ms |
20408 KB |
Output is correct |
16 |
Correct |
0 ms |
20408 KB |
Output is correct |
17 |
Correct |
0 ms |
20408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
20408 KB |
Output is correct |
2 |
Correct |
4 ms |
20408 KB |
Output is correct |
3 |
Correct |
4 ms |
20408 KB |
Output is correct |
4 |
Correct |
4 ms |
20408 KB |
Output is correct |
5 |
Correct |
4 ms |
20408 KB |
Output is correct |
6 |
Correct |
4 ms |
20408 KB |
Output is correct |
7 |
Correct |
4 ms |
20408 KB |
Output is correct |
8 |
Correct |
4 ms |
20408 KB |
Output is correct |
9 |
Correct |
4 ms |
20408 KB |
Output is correct |
10 |
Correct |
0 ms |
20408 KB |
Output is correct |
11 |
Correct |
4 ms |
20408 KB |
Output is correct |
12 |
Correct |
4 ms |
20408 KB |
Output is correct |
13 |
Correct |
0 ms |
20408 KB |
Output is correct |
14 |
Correct |
0 ms |
20408 KB |
Output is correct |
15 |
Correct |
4 ms |
20408 KB |
Output is correct |
16 |
Correct |
4 ms |
20408 KB |
Output is correct |
17 |
Correct |
4 ms |
20408 KB |
Output is correct |
18 |
Correct |
4 ms |
20408 KB |
Output is correct |
19 |
Correct |
4 ms |
20408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2000 ms |
20404 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2000 ms |
20624 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |