Submission #7887

# Submission time Handle Problem Language Result Execution time Memory
7887 2014-08-23T02:50:45 Z xhae 배열 탈출 (GA8_array) C++14
Compilation error
0 ms 0 KB
#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;
}

Compilation message

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]