foo.cpp: In function 'int dp(int, int, int, int)':
foo.cpp:6:5: error: 'i' was not declared in this scope
if(i==N)return a[i];
^
foo.cpp:8:99: error: 'i' was not declared in this scope
if(k1){if(d[k1-1][k2][k3][k4]==0)d[k1-1][k2][k3][k4]=dp(k1-1,k2,k3,k4);an1=d[k1-1][k2][k3][k4]+a[i];}
^
foo.cpp:9:99: error: 'i' was not declared in this scope
if(k2){if(d[k1][k2-1][k3][k4]==0)d[k1][k2-1][k3][k4]=dp(k1,k2-1,k3,k4);an2=d[k1][k2-1][k3][k4]+a[i];}
^
foo.cpp:10:99: error: 'i' was not declared in this scope
if(k3){if(d[k1][k2][k3-1][k4]==0)d[k1][k2][k3-1][k4]=dp(k1,k2,k3-1,k4);an3=d[k1][k2][k3-1][k4]+a[i];}
^
foo.cpp:11:99: error: 'i' was not declared in this scope
if(k4){if(d[k1][k2][k3][k4-1]==0)d[k1][k2][k3][k4-1]=dp(k1,k2,k3,k4-1);an4=d[k1][k2][k3][k4-1]+a[i];}
^