Help me in solving BULBLIFE problem

//My issue is , for input 3 1000 0 0 i am supposes to get 3000 as output, but i am //getting 2975. please help me figure out whats wrong in my code.

using namespace std;

int main() {
// your code goes here
int t; cin>>t;
int sum=0;
int n,x,c; cin>>n>>x;
int m=n-1;
int a[m];
for(int i=0;i<m;i++){
for(int i=0;i<m;i++){
cout<<((c<0) ? 0 : c)<<endl;


return 0;


share problem link.
instead of a[m], go with a[n]

Put int sum=0; inside the while loop. Its keeping the sum value attained in 2nd test case and carrying it over to 3rd one.