Advertisement
Josif_tepe

Untitled

Mar 20th, 2025
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5. const int INF = 2e9;
  6. int main() {
  7.     int height;
  8.    
  9.     int res_max = -INF, res_min = INF;
  10.    
  11.     int tmp_max = -INF, tmp_min = INF;
  12.     bool after_first_zero = false;
  13.     while (cin >> height && height != 11111) {
  14.         if(height == 0) {
  15.             after_first_zero = true;
  16.            
  17.             res_max = max(res_max, tmp_max);
  18.             res_min = min(res_min, tmp_min);
  19.            
  20.             tmp_max = -INF;
  21.             tmp_min = INF;
  22.         }
  23.         else if(after_first_zero) {
  24.             tmp_max = max(tmp_max, height);
  25.             tmp_min = min(tmp_min, height);
  26.         }
  27.     }
  28.    
  29.     cout  << res_max - res_min << endl;
  30.  
  31.    
  32.  
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement