problem statement is here
#include<stdio.h>
int main()
{
long long int t,a,b,ar[1100],br[1100],x,h,k,p,i,j,ans,now;
scanf("%lld",&t);
while(t--)
{
now=0;
ans=10000000;
h=0;k=0;x=0;
scanf("%lld",&a);
for(i=0;i<a;i++)
scanf("%lld",&ar[i]);
scanf("%lld",&b);
for(i=0;i<b;i++)
scanf("%lld",&br[i]);
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
if(ar[i]==br[j])
{
h=1;
ans=0;
break;
}else if(ar[i]>br[j]){
now=ar[i]-br[j];
}else{
now=br[j]-ar[i];
}
ans=(ans<now)?ans:now;
}
if(h==1)
break;
}
printf("%lld\n",ans);
}
return 0;
}
can anyone tell what's wrong with this code:-
ReplyDelete#include
#define ll long long int
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
using namespace std;
int main()
{
ll t,i,j,n,m,k,p;
sf(t);
while(t--)
{
sf(n);
vector v,v1;
v.clear();
v1.clear();
for(i=0;i0)
{
k=v1[p-1];
k=abs(v[i]-k);
j=min(k,j);
}
if(j==0)
break;
}
pf(j);
}
}