I am trying to solve thisproblem. I have implemented the code but there seems to be some mistake with the logic that I am using. I think the problem is when c==4. Can you please help me figure this out.

```
using namespace std;
int main()
{
int n,h;
cin>>n>>h;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int c;
cin>>c;
int j=0;
while(c!=0)
{
bool isPicked = false;
if(c==1 && j>0)
{
j--;
}
if(c==2 && j<n-1)
{
j++;
}
if(c==3)
{
if(!isPicked && a[j] > 0)
{
isPicked = true;
a[j]--;
}
}
if(c==4)
{
if(isPicked && a[j] < h)
{
isPicked = false;
a[j]++;
}
}
cin>>c;
}
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
return 0;
}
```