Racing Horses Easy

Here is my solution regarding the problem Racing Horses .
Solution :- https://www.codechef.com/viewsolution/36128129
Please help me i dont know what is wrong with it.

Pay attention to compiler warnings :slight_smile:

[simon@simon-laptop][10:07:57]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling sukrit_bansal-HORSES.cpp
sukrit_bansal-HORSES.cpp: In function β€˜int main()’:
sukrit_bansal-HORSES.cpp:15:27: warning: β€˜d’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             long long int d;
                           ^
Successful
2 Likes
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    if(t<11)
    {
        while(t>0)
        {
            int n;
            long long int d = INT_MAX;
            long long int temp;
            cin>>n;
            long long int s[n];
            for(int i=0;i<n;i++)
            {
                cin>>s[i];
            }
            for(int i=0;i<n-1;i++)
            {
                for(int j=i+1;j<n;j++)
                {
                    if(s[i]<s[j])
                        temp=s[j]-s[i];
                    else
                        temp=s[i]-s[j];
                    if(temp<d)
                        d=temp;
                }
            }
            cout<<d<<endl;
            t--;
        }
    }
}

Initialize d with max value.