SHARE
TWEET

Untitled

mfgnik Jun 2nd, 2020 626 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. int main() {
  5.     int min_dist = std::numeric_limits<int>::max(), n_1, n_2, n_3, finish = 0;
  6.     bool start = false;
  7.     std::cin >> n_1 >> n_2;
  8.     while (true) {
  9.         std::cin >> n_3;
  10.         if (n_3 == 0) {
  11.             break;
  12.         }
  13.         if (n_2 > n_1 && n_2 > n_3) {
  14.             if (!start) {
  15.                 start = true;
  16.             } else if (finish < min_dist) {
  17.                 min_dist = finish;
  18.                 finish = 0;
  19.             }
  20.         }
  21.         else if (start == 1) {
  22.             finish += 2;
  23.         }
  24.         n_1 = n_2;
  25.         n_2 = n_3;
  26.     }
  27.     if (min_dist == std::numeric_limits<int>::max()) {
  28.         std::cout << 0;
  29.     } else {
  30.         std::cout << min_dist;
  31.     }
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top