fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int maxn=1e7+14;
  4. long long n, m, minvalue = 1e18 , maxvalue = - 1e18;
  5. void solve(){
  6. cin >> n >> m;
  7. for (int i = 1; i <= n; i++){
  8. for (int j = 1; j <= m; j++) {
  9. long long x;
  10. cin >> x;
  11. minvalue = min(minvalue, x);
  12. maxvalue = max(maxvalue, x);
  13. }
  14. }
  15.  
  16. cout << maxvalue - minvalue;
  17. }
  18. int main(){
  19. ios_base::sync_with_stdio(0);
  20. cin.tie(0); cout.tie(0);
  21. if (fopen("input.txt","r")) {
  22. freopen("input.txt","r",stdin);
  23. freopen("output.txt","w",stdout);
  24. }
  25. solve();
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5284KB
stdin
0 0 0
stdout
-2000000000000000000