I've written this code for the problem SUMITR: http://www.spoj.com/problems/SUMITR/. I haven't begun optimising it so that it's less than 256B, but it still doesn't work at this early stage. After taking input of a[1][1] (if n = 3 as in the example), the program stops working. Can someone please tell me why?
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int t, n, m;
cin >> t;
while(t--){
cin >> n;
int **a = new int*[n];
for(int i = 0; i < n; i++){
a[i] = new int[i+1];
for(int j = 0; j < i+1; i++)
cin >> a[i][j];
}
for(int i = n-2; i >= 0; i--)
for(int j = 0; j <= i; j++)
a[i][j]+=max(a[i+1][j],a[i+1][j+1]);
cout << a[0][0] << endl;
for(int i = 0; i < n; i++)
delete [] a[i];
delete [] a;
}
return 0;
}