Uva 11364 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, m, j, b, c, d;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> m;
        int a[m];
        b = 0, c = 100;
        for(j=0;j<m;j++)
        {
            cin >> a[j];
            if(b < a[j])
                b = a[j];
            if(c > a[j])
                c = a[j];
        }
        d = (b - c) * 2;
        cout << d << endl;
    }

    return 0;
}

Comments