Advertisement
Josif_tepe

Untitled

Mar 20th, 2022
968
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <set>
  7. #include <cstring>
  8. #include <cmath>
  9. #include <map>
  10.  #include <bits/stdc++.h>
  11. using namespace std;
  12. int cnt[6666];
  13. int cnt_after_zero[6666];
  14. int main() {
  15.     ios_base::sync_with_stdio(false);
  16.     int num;
  17.     bool first_zero = false;
  18.     memset(cnt_after_zero, 0, sizeof cnt_after_zero);
  19.     while(true) {
  20.         cin >> num;
  21.         if(num == 11111) {
  22.             break;
  23.         }
  24.         if(first_zero and num != 0) {
  25.             cnt[num]++;
  26.             cnt_after_zero[num]++;
  27.         }
  28.         if(num == 0) {
  29.             first_zero = true;
  30.             memset(cnt_after_zero, 0, sizeof cnt_after_zero);
  31.         }
  32.     }
  33.     int b1 = -2e9, s1 = 2e9;
  34.     for(int i = 600; i <= 6000; i++) {
  35.         cnt[i] -= cnt_after_zero[i];
  36.         if(cnt[i] > 0) {
  37.             b1 = max(b1, i);
  38.             s1 = min(s1, i);
  39.         }
  40.     }
  41.     cout << b1 - s1 << endl;
  42.      
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement