답안 #56366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56366 2018-07-11T07:24:14 Z leejseo 배열 탈출 (GA8_array) C++
49 / 100
698 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] = (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 3 ms 432 KB Output is correct
4 Correct 3 ms 516 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 3 ms 572 KB Output is correct
7 Correct 3 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 3 ms 700 KB Output is correct
10 Correct 3 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 700 KB Output is correct
13 Correct 3 ms 700 KB Output is correct
14 Correct 3 ms 700 KB Output is correct
15 Correct 17 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 700 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 3 ms 700 KB Output is correct
4 Correct 9 ms 700 KB Output is correct
5 Correct 2 ms 700 KB Output is correct
6 Correct 3 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 3 ms 700 KB Output is correct
9 Correct 5 ms 700 KB Output is correct
10 Correct 3 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 3 ms 700 KB Output is correct
13 Correct 2 ms 700 KB Output is correct
14 Correct 3 ms 700 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 3 ms 700 KB Output is correct
19 Correct 2 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2716 KB Output is correct
2 Correct 11 ms 2756 KB Output is correct
3 Correct 9 ms 2756 KB Output is correct
4 Correct 10 ms 2756 KB Output is correct
5 Correct 9 ms 2756 KB Output is correct
6 Correct 19 ms 2756 KB Output is correct
7 Correct 12 ms 2756 KB Output is correct
8 Correct 11 ms 2876 KB Output is correct
9 Correct 16 ms 2876 KB Output is correct
10 Correct 10 ms 2876 KB Output is correct
11 Correct 11 ms 2876 KB Output is correct
12 Correct 16 ms 2876 KB Output is correct
13 Correct 9 ms 2876 KB Output is correct
14 Correct 11 ms 2876 KB Output is correct
15 Correct 9 ms 2876 KB Output is correct
16 Correct 9 ms 2876 KB Output is correct
17 Correct 9 ms 2876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 698 ms 39532 KB Output is correct
2 Correct 666 ms 39532 KB Output is correct
3 Correct 586 ms 39616 KB Output is correct
4 Correct 602 ms 56508 KB Output is correct
5 Correct 485 ms 56508 KB Output is correct
6 Correct 576 ms 56508 KB Output is correct
7 Correct 594 ms 56516 KB Output is correct
8 Runtime error 652 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.706', 'max-rss': '39548', 'csw-forced': '206', 'cg-mem': '66560', 'time': '0.652', 'csw-voluntary': '6'} 65536
9 Halted 0 ms 0 KB -