 Problem Code Racing horses Easy Level
IM JUST STARTING OUT Guys a simple question where an array is given, and we have to find the minimum difference between any two elements in the array. eg
4 9 1 32 13 answer is 3

Input:
First line of the input file contains a single integer T, the number of test cases.
Every test case starts with a line containing the integer N.
The next line contains N space separated integers where the i-th integer is S[i].

Output:
For each test case, output a single line containing the minimum difference that is possible.

Constraints:
1 ≤ T ≤ 10
2 ≤ N ≤ 5000
1 ≤ S[i] ≤ 1000000000

I need Help . I get a wrong answer(RED CROSS) every time !!!

``````   #include <iostream>
#include<vector>
#include<stdio.h>

using namespace std;

int main()
{
int t;
int n;
int i;
scanf("%d %d",&t,&n);
vector<long long int> a(n);
for(int w=0;w<t;w++)
``{
for(i=0;i<n;i++)
scanf("%lld",&a[i]);

long long int diff;
diff=99999999999;

for(i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
long long int x=a[i]-a[j];
if(x<0)
x=-x;

if(x<diff)
diff=x;
}
printf("%lld",diff);
}
return 0;
}``````

Mistakes u did :

1.U have took no.of test cases(t) and length of d array(n) only once,whereas length of d array is different for different test cases !
2.Not printing answer in a new line…!

here is ur AC code : https://www.codechef.com/viewsolution/15539027…!

Happy coding : )