답안 #56376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56376 2018-07-11T07:42:03 Z leejseo 배열 탈출 (GA8_array) C++
49 / 100
804 ms 66560 KB
#include <stdio.h>
#include <algorithm>
#define INF 1000000000
using namespace std;
int C[2223], B[2223], CUR[2223], BF[2223], N;

void input(){
	scanf("%d", &N);
}

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++){
			B[j] = C[j];
			scanf("%d", &C[j]);
			if (i + j == 2){
				CUR[1] = 0;
				BF[1] = 0;
				continue;
			}
			CUR[j] = min(BF[j] + (B[j] > C[j]? 0 : C[j] - B[j] + 1), CUR[j-1] + (C[j-1]  > C[j]? 0 : C[j] - C[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: In function 'void DP()':
array.cpp:19:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &C[j]);
    ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 1 ms 616 KB Output is correct
8 Correct 2 ms 616 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 2 ms 616 KB Output is correct
11 Correct 2 ms 616 KB Output is correct
12 Correct 2 ms 616 KB Output is correct
13 Correct 3 ms 616 KB Output is correct
14 Correct 3 ms 616 KB Output is correct
15 Correct 2 ms 616 KB Output is correct
16 Correct 2 ms 616 KB Output is correct
17 Correct 3 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 616 KB Output is correct
2 Correct 3 ms 616 KB Output is correct
3 Correct 2 ms 616 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Correct 2 ms 616 KB Output is correct
6 Correct 3 ms 616 KB Output is correct
7 Correct 3 ms 616 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 2 ms 624 KB Output is correct
10 Correct 3 ms 624 KB Output is correct
11 Correct 3 ms 624 KB Output is correct
12 Correct 2 ms 624 KB Output is correct
13 Correct 2 ms 624 KB Output is correct
14 Correct 4 ms 624 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 2 ms 624 KB Output is correct
17 Correct 3 ms 624 KB Output is correct
18 Correct 3 ms 624 KB Output is correct
19 Correct 2 ms 624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 624 KB Output is correct
2 Correct 8 ms 624 KB Output is correct
3 Correct 11 ms 624 KB Output is correct
4 Correct 9 ms 624 KB Output is correct
5 Correct 9 ms 676 KB Output is correct
6 Correct 11 ms 676 KB Output is correct
7 Correct 12 ms 676 KB Output is correct
8 Correct 8 ms 676 KB Output is correct
9 Correct 9 ms 676 KB Output is correct
10 Correct 8 ms 676 KB Output is correct
11 Correct 9 ms 676 KB Output is correct
12 Correct 8 ms 676 KB Output is correct
13 Correct 8 ms 676 KB Output is correct
14 Correct 13 ms 676 KB Output is correct
15 Correct 14 ms 676 KB Output is correct
16 Correct 8 ms 676 KB Output is correct
17 Correct 8 ms 676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 804 ms 680 KB Output is correct
2 Correct 683 ms 684 KB Output is correct
3 Correct 658 ms 684 KB Output is correct
4 Correct 661 ms 13604 KB Output is correct
5 Correct 572 ms 13604 KB Output is correct
6 Correct 675 ms 13604 KB Output is correct
7 Correct 691 ms 13604 KB Output is correct
8 Correct 627 ms 13604 KB Output is correct
9 Correct 714 ms 13612 KB Output is correct
10 Correct 521 ms 13620 KB Output is correct
11 Correct 481 ms 13620 KB Output is correct
12 Correct 469 ms 13620 KB Output is correct
13 Correct 495 ms 13624 KB Output is correct
14 Correct 590 ms 13624 KB Output is correct
15 Correct 533 ms 25904 KB Output is correct
16 Correct 612 ms 42816 KB Output is correct
17 Correct 636 ms 59696 KB Output is correct
18 Runtime error 582 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '0.654', 'max-rss': '1148', 'csw-forced': '158', 'cg-mem': '66560', 'time': '0.582', 'csw-voluntary': '4'} 65536
19 Halted 0 ms 0 KB -