Submission #56372

# Submission time Handle Problem Language Result Execution time Memory
56372 2018-07-11T07:30:57 Z leejseo 배열 탈출 (GA8_array) C++
49 / 100
927 ms 66560 KB
#include <stdio.h>
#include <algorithm>
#define INF 1000000000
using namespace std;
int A[2223][2223], D[2223][2223], N;

void input(){
	scanf("%d", &N);
	for (int i=1; i<=N; i++){
		for (int j=1; j<=N; j++){
			scanf("%d", &A[i][j]);
		}
	}
}

void DP(){
	D[1][1] = 0;
	for (int i=0; i<=N; i++){
		D[0][i] = INF;
		D[i][0] = INF;
	}
	for (int i=1; i<=N; i++){
		for (int j=1; j<=N; j++){
			if (i + j == 2) continue;
			D[i][j] = min(D[i-1][j] + (A[i-1][j] > A[i][j]? 0 : A[i][j] - A[i-1][j] + 1), D[i][j-1] + (A[i][j-1]  > A[i][j]? 0 : A[i][j] - A[i][j-1] + 1));		
		}
	}
}

int main(void){
	input();
	DP();
	printf("%d\n", D[N][N]);
}

Compilation message

array.cpp: In function 'void input()':
array.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
array.cpp:11:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &A[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 648 KB Output is correct
7 Correct 2 ms 648 KB Output is correct
8 Correct 2 ms 648 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 648 KB Output is correct
13 Correct 2 ms 648 KB Output is correct
14 Correct 2 ms 648 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 2 ms 648 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 648 KB Output is correct
2 Correct 3 ms 648 KB Output is correct
3 Correct 2 ms 648 KB Output is correct
4 Correct 3 ms 648 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Correct 3 ms 648 KB Output is correct
7 Correct 3 ms 648 KB Output is correct
8 Correct 3 ms 648 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 3 ms 668 KB Output is correct
17 Correct 2 ms 668 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 3 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2732 KB Output is correct
2 Correct 13 ms 2832 KB Output is correct
3 Correct 18 ms 2832 KB Output is correct
4 Correct 10 ms 2832 KB Output is correct
5 Correct 11 ms 2832 KB Output is correct
6 Correct 10 ms 2832 KB Output is correct
7 Correct 10 ms 2832 KB Output is correct
8 Correct 9 ms 2832 KB Output is correct
9 Correct 8 ms 2832 KB Output is correct
10 Correct 12 ms 2832 KB Output is correct
11 Correct 14 ms 2832 KB Output is correct
12 Correct 11 ms 2832 KB Output is correct
13 Correct 14 ms 2832 KB Output is correct
14 Correct 10 ms 2832 KB Output is correct
15 Correct 10 ms 2860 KB Output is correct
16 Correct 13 ms 2860 KB Output is correct
17 Correct 10 ms 2860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 808 ms 39252 KB Output is correct
2 Correct 768 ms 39264 KB Output is correct
3 Correct 692 ms 39296 KB Output is correct
4 Correct 674 ms 56472 KB Output is correct
5 Correct 512 ms 56472 KB Output is correct
6 Correct 645 ms 56472 KB Output is correct
7 Correct 825 ms 56472 KB Output is correct
8 Correct 927 ms 56536 KB Output is correct
9 Correct 830 ms 56552 KB Output is correct
10 Correct 695 ms 56552 KB Output is correct
11 Runtime error 696 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.748', 'max-rss': '39432', 'csw-forced': '140', 'cg-mem': '66560', 'time': '0.696', 'csw-voluntary': '5'} 65536
12 Halted 0 ms 0 KB -