我目前是NA(50),第十題會出現RE的狀況,請問我的程式哪裡出錯了
#include <iostream>
#include <climits>
using namespace std;
//https://zerojudge.tw/ShowProblem?problemid=f314
int main()
{
int m,n;
cin>>m>>n;
int tmp_map[m][n];
int r[n] = {0};
for( int i = 0 ; i < m ; i++ )
{
for( int j = 0 ; j < n ; j++ )
{
tmp_map[i][j] = 0;
}
}
for( int i = 0 ; i < m ; i++ )
{
for( int j = 0 ; j < n ; j++ )
{
cin>>r[j];
}
for( int j = 0 ; j < n ; j++ )
{
int biggest = INT_MIN;
int tmp = 0;
for( int g = 0 ; g <= j ; g++ )
{
if( i != 0 )
{
tmp += tmp_map[i-1][g];
}
for( int x = g ; x <= j ; x++ )
{
tmp += r[x];
}
biggest = max( biggest, tmp );
tmp = 0;
}
tmp = 0;
for( int g = (n-1) ; g >= j ; g-- )
{
if( i != 0 )
{
tmp += tmp_map[i-1][g];
}
for( int x = g ; x >= j ; x-- )
{
tmp += r[x];
}
biggest = max( biggest, tmp );
tmp = 0;
}
tmp_map[i][j] += biggest;
}
}
int answer = 0;
int tmpp = 0;
for( int i = 0 ; i < n ; i++ )
{
tmpp = tmp_map[m-1][i];
answer = max( answer, tmpp );
}
cout<<answer;
}