Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "pch.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- #define max(a,b) (((a) > (b)) ? (a) : (b))
- int main()
- {
- int prev, cur;
- cin >> prev;
- if (prev)
- {
- cin >> cur;
- int count = 1, count_max = 1;
- int diff_prev = cur - prev;
- while (cur)
- {
- int diff_cur = cur - prev;
- if (diff_prev * diff_cur > 0)
- {
- count++;
- }
- else if (diff_prev * diff_cur == 0)
- {
- count = 1;
- }
- else
- {
- count = 2;
- }
- count_max = max(count_max, count);
- diff_prev = diff_cur;
- prev = cur;
- cin >> cur;
- }
- cout << count_max;
- }
- else
- {
- cout << 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement