fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. int n;
  9. cin >> n;
  10.  
  11. vector<int> ted(n);
  12.  
  13. for(int i =0; i < ted.size(); i++){
  14. cin >> ted[i];
  15. }
  16.  
  17. sort(ted.begin(), ted.end());
  18.  
  19. int roznica =0;
  20.  
  21. roznica = (ted[ted.size()-1] - ted[0]) ;
  22.  
  23. cout << roznica;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5320KB
stdin
4
1 2 7 -6
stdout
13