here's the code
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("v.in");
ofstream g("v.out");
int v[2000][2000];
int main()
{
int s = 0;
int imax, jmax, smax = 0;
int n, m;
int d;
f >> m >> n;
for(int i = 1; i <= m; i++)
{
for(int j = 1; j<=n; j++)
{
f >> v[i][j];
}
}
int i = 1, j = 1;
for(i = 1; i + 2 <= n; i++)
{
for(d = 1; d < m && i + d * 2 <= n; d++)
{
int i2 = i + d * 2;
s = 0;
int ii1 = i;
int ii2 = i2;
for(j = 1; j <= d + 1; j++)
{
s = s + v[j][ii1++];
}
for(j=1;j<d+1;j++)
{
s = s + v[j][ii2--];
}
if(s > smax)
{
smax = s;
imax = i;
jmax = d + 1;
}
}
}
g << smax << ' ' << imax << ' ' << jmax;
f.close();
g.close();
return 0;
}
the program must read the matrix in V starting from first line. every time i get the terminated with status -1073741510 and i cant find why.
1 ≤ m, n ≤ 1500
It has to show the max sum route showing, smax, and starting column and last row as in the example:
v.in
5 10
1 2 1 1 1 1 1 1 1 1
1 2 -1 20 -1 -1 -1 1 -1 2
-3 -3 -4 -5 -6 -7 -8 -9 20 -1
-2 -4 -5 -6 -6 -7 -8 -9 -10 -1
-20 -40 -4 -5 -6 -6 -7 -8 -9 -10
v.out
22 3 2
I am begginer , please help