제출 #7887

#제출 시각아이디문제언어결과실행 시간메모리
7887xhae배열 탈출 (GA8_array)C++14
컴파일 에러
0 ms0 KiB
#include <cstdio>
#include <cstring>

int arr[2222][2222], n;
int dp[2222][2222];

int getAns(int y, int x)
{
	int &ret = dp[y][x];
    if(ret != -1) return ret;
    
    if(y == n - 1 and x == n - 1) ret = 0;
    else
    {
    	ret = (1 << 30);
        if(y < n - 1) ret = min(ret, getAns(y + 1, x) + max(0, arr[y + 1][x] + 1 - arr[y][x]));
        if(x < n - 1) ret = min(ret, getAns(y, x + 1) + max(0, arr[y][x + 1] + 1 - arr[y][x]));
    }
    
    return ret;
}   

int main(void)
{
	scanf("%d", &n);
    for(int i = 0; i < n; i++)
    	for(int j = 0; j < n; j++)
        	scanf("%d", arr[i] + j);
    
    memset(dp, -1, sizeof(dp));
    printf("%d\n", getAns(0, 0));
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

array.cpp: In function 'int getAns(int, int)':
array.cpp:16:93: error: 'max' was not declared in this scope
array.cpp:16:94: error: 'min' was not declared in this scope
array.cpp:17:93: error: 'max' was not declared in this scope
array.cpp:17:94: error: 'min' was not declared in this scope
array.cpp: In function 'int main()':
array.cpp:25:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
array.cpp:28:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]