Submission #56370

# Submission time Handle Problem Language Result Execution time Memory
56370 2018-07-11T07:29:13 Z leejseo 배열 탈출 (GA8_array) C++
49 / 100
920 ms 66560 KB
#include <stdio.h>
#include <algorithm>
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] = (int)1e9;
		D[i][0] = (int)1e9;
	}
	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:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
array.cpp:10: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 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 3 ms 508 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 3 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 3 ms 696 KB Output is correct
15 Correct 3 ms 696 KB Output is correct
16 Correct 2 ms 696 KB Output is correct
17 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 712 KB Output is correct
2 Correct 4 ms 712 KB Output is correct
3 Correct 2 ms 712 KB Output is correct
4 Correct 2 ms 712 KB Output is correct
5 Correct 4 ms 712 KB Output is correct
6 Correct 3 ms 712 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 2 ms 712 KB Output is correct
9 Correct 3 ms 712 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 3 ms 712 KB Output is correct
12 Correct 3 ms 712 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
18 Correct 2 ms 712 KB Output is correct
19 Correct 2 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2732 KB Output is correct
2 Correct 13 ms 2732 KB Output is correct
3 Correct 11 ms 2732 KB Output is correct
4 Correct 14 ms 2732 KB Output is correct
5 Correct 13 ms 2756 KB Output is correct
6 Correct 11 ms 2756 KB Output is correct
7 Correct 12 ms 2756 KB Output is correct
8 Correct 8 ms 2756 KB Output is correct
9 Correct 8 ms 2756 KB Output is correct
10 Correct 11 ms 2756 KB Output is correct
11 Correct 10 ms 2756 KB Output is correct
12 Correct 8 ms 2756 KB Output is correct
13 Correct 8 ms 2756 KB Output is correct
14 Correct 9 ms 2756 KB Output is correct
15 Correct 9 ms 2756 KB Output is correct
16 Correct 12 ms 2756 KB Output is correct
17 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 865 ms 39468 KB Output is correct
2 Correct 829 ms 39548 KB Output is correct
3 Correct 825 ms 39548 KB Output is correct
4 Correct 745 ms 56388 KB Output is correct
5 Correct 613 ms 56388 KB Output is correct
6 Correct 920 ms 56388 KB Output is correct
7 Correct 716 ms 56424 KB Output is correct
8 Correct 608 ms 56680 KB Output is correct
9 Correct 616 ms 56680 KB Output is correct
10 Runtime error 535 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.596', 'max-rss': '39428', 'csw-forced': '170', 'cg-mem': '66560', 'time': '0.535', 'csw-voluntary': '7'} 65536
11 Halted 0 ms 0 KB -