fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n;
  11. cin >> n;
  12. vector<int> a(n);
  13. for (int &x : a) cin >> x;
  14. sort(a.begin(), a.end());
  15. cout << a[n - 1] - a[0] << "\n";
  16. }
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5280KB
stdin
4
2
1 3
5
5 4 3 2 1
3
5 6 7
3
1 11 10
stdout
2
4
2
10