Problem Name :  Parking

Problem Link : See Problem : Uva – 11364

Solution  :

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a[100],t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int s=100000,m=0;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++){
            if(a[i]<s)
            {
                s=a[i];
            }
        }
        for(int j=0;j<n;j++)
        {
            if(a[j]>m)
                m=a[j];
        }
        cout<<((m-s)*2)<<endl;
    }

    return 0;
}
Advertisements