Submission #56375

# Submission time Handle Problem Language Result Execution time Memory
56375 2018-07-11T07:40:09 Z leejseo 배열 탈출 (GA8_array) C++
49 / 100
788 ms 66560 KB
#include <stdio.h>
#include <algorithm>
#define INF 1000000000
using namespace std;
int A[2223][2223], CUR[2223], BF[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(){
	for (int i=0; i<=N; i++){
		BF[i] = INF;
	}	
	for (int i=1; i<=N; i++){
		CUR[0] = INF;
		for (int j=1; j<=N; j++){
			if (i + j == 2){
				CUR[1] = 0;
				BF[1] = 0;
				continue;
			}
			CUR[j] = min(BF[j] + (A[i-1][j] > A[i][j]? 0 : A[i][j] - A[i-1][j] + 1), CUR[j-1] + (A[i][j-1]  > A[i][j]? 0 : A[i][j] - A[i][j-1] + 1));		
			BF[j] = CUR[j];
		}
	}
}

int main(void){
	input();
	DP();
	printf("%d\n", CUR[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 376 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 4 ms 516 KB Output is correct
6 Correct 3 ms 516 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 576 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 2 ms 588 KB Output is correct
12 Correct 2 ms 608 KB Output is correct
13 Correct 2 ms 608 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 3 ms 608 KB Output is correct
17 Correct 3 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 3 ms 620 KB Output is correct
4 Correct 3 ms 752 KB Output is correct
5 Correct 2 ms 752 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
8 Correct 2 ms 752 KB Output is correct
9 Correct 3 ms 752 KB Output is correct
10 Correct 2 ms 752 KB Output is correct
11 Correct 3 ms 752 KB Output is correct
12 Correct 2 ms 752 KB Output is correct
13 Correct 2 ms 752 KB Output is correct
14 Correct 2 ms 752 KB Output is correct
15 Correct 3 ms 752 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 2 ms 752 KB Output is correct
18 Correct 2 ms 752 KB Output is correct
19 Correct 2 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1724 KB Output is correct
2 Correct 18 ms 1724 KB Output is correct
3 Correct 9 ms 1724 KB Output is correct
4 Correct 10 ms 1724 KB Output is correct
5 Correct 11 ms 1724 KB Output is correct
6 Correct 9 ms 1724 KB Output is correct
7 Correct 16 ms 1724 KB Output is correct
8 Correct 9 ms 1724 KB Output is correct
9 Correct 8 ms 1724 KB Output is correct
10 Correct 9 ms 1724 KB Output is correct
11 Correct 9 ms 1724 KB Output is correct
12 Correct 10 ms 1724 KB Output is correct
13 Correct 12 ms 1724 KB Output is correct
14 Correct 12 ms 1804 KB Output is correct
15 Correct 9 ms 1804 KB Output is correct
16 Correct 11 ms 1804 KB Output is correct
17 Correct 17 ms 1804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 788 ms 20192 KB Output is correct
2 Correct 779 ms 20192 KB Output is correct
3 Correct 711 ms 20220 KB Output is correct
4 Correct 693 ms 37084 KB Output is correct
5 Correct 740 ms 37084 KB Output is correct
6 Correct 653 ms 37084 KB Output is correct
7 Correct 725 ms 37112 KB Output is correct
8 Correct 760 ms 37180 KB Output is correct
9 Correct 744 ms 37248 KB Output is correct
10 Correct 640 ms 37348 KB Output is correct
11 Correct 642 ms 37348 KB Output is correct
12 Correct 642 ms 51720 KB Output is correct
13 Correct 518 ms 63992 KB Output is correct
14 Runtime error 635 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.709', 'max-rss': '20140', 'csw-forced': '161', 'cg-mem': '66560', 'time': '0.635', 'csw-voluntary': '4'} 65536
15 Halted 0 ms 0 KB -