Running code gives TLE and SIGTSTP error on compiler but it gets accepted on submitting


#1

https://www.codechef.com/ZCOPRAC/problems/ZCO14001
#include<bits/stdc++.h>
using namespace std;

int main()
{
long long n,i,crane_pos=0,crane_occ=0;
long long h;
int move;
cin>>n>>h;
vector inp(n);
for(i=0;i<n;i++)
{
scanf("%lld",&inp[i]);
}

while(1)
{
scanf("%d",&move);
if (move==0) break;

 else if(move==1 && crane_pos>0) crane_pos--;
 
  else if(move==2 && crane_pos<n-1) crane_pos++;
 
  else if(move==3 && crane_occ==0 && inp[crane_pos]>0)
  {
          crane_occ=1;
          inp[crane_pos]--;      
  }
  else if(move==4 && inp[crane_pos]<h && crane_occ==1)
      {
          crane_occ=0;
          inp[crane_pos]++;
      }
  else continue;

}

for(i=0;i<n;i++)
{
printf("%lld ",inp[i]);
}

}

Can someone explain this issue