this is the problem
https://www.codechef.com/JUNE21C/problems/SHROUTE
i’m getting TLE
this is my code can you suggest any alterations
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;cin>>t;
while(t–)
{
ll n,m;
cin>>n>>m;
ll a[100000],b[100000];
for(ll i=0;i<n;i++)
cin>>a[i];
for(ll i=0;i<m;i++)
cin>>b[i];
for(ll i=0;i<m;i++)
{
if(a[b[i]-1]==1||a[b[i]-1]==2)
{
cout<<0<<" ";
continue;
}
else
{
ll posn=b[i]-1;
ll lmin=0;// values of minutes
ll rmin=0;
ll count=-1;
int l=posn,r=posn;
for(;l>=0||r<n;l--,r++)
{
count++;
if(a[l]==1)
{
lmin=count;
break;
}
if(a[r]==2)
{
rmin=count;
break;
}
}
if(l<0&&r>=n)
cout<<"-1";
else
(lmin)?cout<<lmin:cout<<rmin;
cout<<" ";
}
}
cout<<"\n";
}
return 0;
}