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(), before, now, next, current_dist = 0;
- bool start = false;
- std::cin >> before >> now;
- while (true) {
- std::cin >> next;
- if (next == 0) {
- break;
- }
- if (now > before && now > next) {
- if (!start) {
- start = true;
- } else if (current_dist < min_dist) {
- min_dist = current_dist;
- }
- current_dist = 0;
- }
- ++current_dist;
- before = now;
- now = next;
- }
- 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