Advertisement
Josif_tepe

Untitled

Mar 22nd, 2024
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <set>
  5. using namespace std;
  6. typedef long long ll;
  7.  
  8.  
  9.  
  10. int main() {
  11.     bool prva_nula = false;
  12.     int tmp_min = 2e9, tmp_max = -2e9;
  13.     int global_min = 2e9, global_max = -2e9;
  14.     for(int i = 0; i < 1000000; i++) {
  15.         int x;
  16.         cin >> x;
  17.         if(x == 11111) {
  18.             break;
  19.         }
  20.         if(x == 0 and !prva_nula) {
  21.             prva_nula = true;
  22.             continue;
  23.         }
  24.         if(x !=0 and prva_nula) {
  25.             tmp_min = min(tmp_min, x);
  26.             tmp_max = max(tmp_max, x);
  27.         }
  28.         if(x == 0) {
  29.             global_max = max(global_max, tmp_max);
  30.             global_min = min(global_min, tmp_min);
  31.            
  32.             tmp_max = -2e9;
  33.             tmp_min = 2e9;
  34.            
  35.         }
  36.     }
  37.     cout << global_max - global_min << endl;
  38.     return 0;
  39. }
  40. //   2 1 3 3
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement