Submission #56358

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

inline bool valid(int i, int j) {
	return 0<=i && i<N && 0<=j && j<N;
}

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

void DP(){
	D[0][0] = 0;
	for (int i=0; i<N; i++){
		for (int j=0; j<N; j++){
			if (i == 0 && j == 0) continue;
			D[i][j] = (int)1e9;
			if (valid(i-1, j)) D[i][j] = min(D[i][j], D[i-1][j] + max(0, A[i][j] - A[i-1][j] + 1));
			if (valid(i, j-1)) D[i][j] = min(D[i][j], D[i][j-1] + max(0, A[i][j] - A[i][j-1] + 1));
		}
	}
}

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

Compilation message

array.cpp: In function 'void input()':
array.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
array.cpp:14: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 3 ms 472 KB Output is correct
3 Correct 3 ms 552 KB Output is correct
4 Correct 3 ms 616 KB Output is correct
5 Correct 3 ms 616 KB Output is correct
6 Correct 3 ms 616 KB Output is correct
7 Correct 8 ms 616 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 2 ms 616 KB Output is correct
10 Correct 1 ms 616 KB Output is correct
11 Correct 3 ms 616 KB Output is correct
12 Correct 3 ms 616 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 2 ms 644 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 3 ms 676 KB Output is correct
17 Correct 3 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 688 KB Output is correct
2 Correct 2 ms 692 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
4 Correct 3 ms 700 KB Output is correct
5 Correct 3 ms 704 KB Output is correct
6 Correct 2 ms 708 KB Output is correct
7 Correct 4 ms 712 KB Output is correct
8 Correct 3 ms 716 KB Output is correct
9 Correct 3 ms 720 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 4 ms 732 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 744 KB Output is correct
15 Correct 3 ms 744 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 2 ms 752 KB Output is correct
18 Correct 3 ms 756 KB Output is correct
19 Correct 3 ms 816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2940 KB Output is correct
2 Correct 14 ms 2940 KB Output is correct
3 Correct 15 ms 2940 KB Output is correct
4 Correct 18 ms 2940 KB Output is correct
5 Correct 26 ms 2940 KB Output is correct
6 Correct 12 ms 2992 KB Output is correct
7 Correct 13 ms 2992 KB Output is correct
8 Correct 11 ms 2992 KB Output is correct
9 Correct 13 ms 2992 KB Output is correct
10 Correct 13 ms 2992 KB Output is correct
11 Correct 15 ms 2992 KB Output is correct
12 Correct 16 ms 2992 KB Output is correct
13 Correct 12 ms 2992 KB Output is correct
14 Correct 9 ms 2992 KB Output is correct
15 Correct 13 ms 2992 KB Output is correct
16 Correct 14 ms 2992 KB Output is correct
17 Correct 13 ms 2992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 833 ms 39484 KB Output is correct
2 Correct 971 ms 39484 KB Output is correct
3 Correct 913 ms 39624 KB Output is correct
4 Correct 905 ms 56608 KB Output is correct
5 Runtime error 862 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.947', 'max-rss': '36052', 'csw-forced': '225', 'cg-mem': '66560', 'time': '0.862', 'csw-voluntary': '5'} 65536
6 Halted 0 ms 0 KB -