Advertisement
juanjo12x

UVA_11364_Parking

May 23rd, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4.  
  5. int main(int argc, char** argv) {
  6.     int t,n ; /*number of test cases and coordinates*/
  7.     int m;
  8.     int i;/*index of for*/
  9.     int max,min;/*max and min of the inputs*/
  10.     int result; /*result*/
  11.     scanf("%d",&t);
  12.     while(t--){
  13.         min=INT_MAX;
  14.         max=INT_MIN;
  15.         scanf("%d",&n);
  16.         for (i=0;i<n;i++){
  17.             scanf("%d",&m);
  18.             if (m<min) min=m;
  19.             if (m>max) max=m;
  20.            
  21.         }
  22.         result=(max-min)*2;
  23.         printf("%d\n",result);
  24.        
  25.        
  26.     }
  27.     return (EXIT_SUCCESS);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement