답안 #56365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56365 2018-07-11T07:23:17 Z leejseo 배열 탈출 (GA8_array) C++
6 / 100
759 ms 39536 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=1; i<=N; i++){
		for (int j=1; j<=N; j++){
			if (i == 1 && j == 1) continue;
			D[i][j] = (int)1e9;
			D[i][j] = min(D[i][j], D[i-1][j] + max(0, A[i][j] - A[i-1][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][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 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 520 KB Output is correct
5 Correct 2 ms 524 KB Output is correct
6 Correct 2 ms 528 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 3 ms 624 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 664 KB Output is correct
14 Correct 2 ms 664 KB Output is correct
15 Correct 2 ms 664 KB Output is correct
16 Correct 2 ms 680 KB Output is correct
17 Correct 2 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 688 KB Output is correct
2 Correct 2 ms 692 KB Output is correct
3 Incorrect 3 ms 692 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 2876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 759 ms 39536 KB Output isn't correct
2 Halted 0 ms 0 KB -