Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <limits>
- int main() {
- int min_dist = std::numeric_limits<int>::max(), n_1, n_2, n_3, finish = 0;
- bool start = false;
- std::cin >> n_1 >> n_2;
- while (true) {
- std::cin >> n_3;
- if (n_3 == 0) {
- break;
- }
- if (n_2 > n_1 && n_2 > n_3) {
- if (!start) {
- start = true;
- } else if (finish < min_dist) {
- min_dist = finish;
- finish = 0;
- }
- }
- else if (start == 1) {
- finish += 2;
- }
- n_1 = n_2;
- n_2 = n_3;
- }
- if (min_dist == std::numeric_limits<int>::max()) {
- std::cout << 0;
- } else {
- std::cout << min_dist;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement