Advertisement
audreych

12606 - Happy New Year

Feb 20th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int arr[200001];
  4. int main(){
  5.     int N;
  6.     scanf("%d", &N);
  7.     int max = 0;
  8.     int min = 1000000001;
  9.     for(int i = 0; i < N + 1; i++){
  10.         scanf("%d", &arr[i]);
  11.         if(max < arr[i]) max = arr[i];
  12.         if(min > arr[i]) min = arr[i];
  13.     }
  14.    
  15.     int distance = 0;
  16.     distance = 2*(max - min);
  17.     printf("%d\n", distance);
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement