답안 #56368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56368 2018-07-11T07:28:21 Z leejseo 배열 탈출 (GA8_array) C++
49 / 100
721 ms 66560 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
int A[2230][2230], D[2230][2230], 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 == 1 && j == 1) 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]);
    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 7 ms 488 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 652 KB Output is correct
6 Correct 2 ms 652 KB Output is correct
7 Correct 2 ms 652 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 3 ms 652 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 2 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 652 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
3 Correct 2 ms 652 KB Output is correct
4 Correct 2 ms 652 KB Output is correct
5 Correct 3 ms 672 KB Output is correct
6 Correct 5 ms 672 KB Output is correct
7 Correct 3 ms 672 KB Output is correct
8 Correct 3 ms 672 KB Output is correct
9 Correct 3 ms 684 KB Output is correct
10 Correct 2 ms 684 KB Output is correct
11 Correct 2 ms 684 KB Output is correct
12 Correct 2 ms 684 KB Output is correct
13 Correct 3 ms 684 KB Output is correct
14 Correct 3 ms 684 KB Output is correct
15 Correct 2 ms 684 KB Output is correct
16 Correct 2 ms 684 KB Output is correct
17 Correct 2 ms 740 KB Output is correct
18 Correct 2 ms 740 KB Output is correct
19 Correct 3 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2748 KB Output is correct
2 Correct 13 ms 2748 KB Output is correct
3 Correct 11 ms 2748 KB Output is correct
4 Correct 11 ms 2876 KB Output is correct
5 Correct 10 ms 2876 KB Output is correct
6 Correct 12 ms 2876 KB Output is correct
7 Correct 12 ms 2876 KB Output is correct
8 Correct 12 ms 2876 KB Output is correct
9 Correct 9 ms 2876 KB Output is correct
10 Correct 9 ms 2876 KB Output is correct
11 Correct 9 ms 2876 KB Output is correct
12 Correct 9 ms 2876 KB Output is correct
13 Correct 9 ms 2876 KB Output is correct
14 Correct 10 ms 2876 KB Output is correct
15 Correct 10 ms 2876 KB Output is correct
16 Correct 10 ms 2876 KB Output is correct
17 Correct 10 ms 2876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 688 ms 39464 KB Output is correct
2 Correct 700 ms 39528 KB Output is correct
3 Correct 721 ms 39528 KB Output is correct
4 Correct 611 ms 56636 KB Output is correct
5 Correct 500 ms 56636 KB Output is correct
6 Correct 583 ms 56636 KB Output is correct
7 Correct 642 ms 56636 KB Output is correct
8 Correct 703 ms 56664 KB Output is correct
9 Runtime error 670 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.730', 'max-rss': '39544', 'csw-forced': '182', 'cg-mem': '66560', 'time': '0.670', 'csw-voluntary': '6'} 65536
10 Halted 0 ms 0 KB -