Please help me out in this problem

My logic is same like of the other programs which are correct for all test case but my program is true for only 3 test cases.plz tell me what error I am doing…
Question:- Video game(ZCO14001)
My attempt:-
#include
#include
using namespace std;
int main() {
long long int n,h,i,j=0;
int k=0;
scanf("%lld",&n);
scanf("%lld",&h);
long long nob[n],com;
for(i=0;i<n;i++){
scanf("%lld",&nob[i]);
}
while(com!=0){
cin>>com;
if(com==1){
if(j>0){j=j-1;}
}
if(com==2){ if(j<n-1){j=j+1;}
}
if(com==3){if((k<1)&&nob[j]>0)
{nob[j]=nob[j]-1;k++;}
}
if(com==4){if(k==1&&nob[j]<h){nob[j]=nob[j]+1;k=k-1;}
}
}
for(i=0;i<n;i++)
{
cout<<nob[i];
}

return 0;

}