Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- int a, b;
- int k = 0;
- cin >> a >> b;
- int j = 1;
- if (a == b)
- {
- while ((a == b) && (j < n))
- {
- a = b;
- cin >> b;
- k = 6;
- j++;
- }
- }
- if (a > b)
- {
- for (int i = 1; i < n; i++)
- {
- if ((a > b) && ((k == 1) || (k == 0) || (k == 6)))
- {
- a = b;
- cin >> b;
- k = 1;
- continue;
- }
- if ((a >= b) && ((k == 1) || (k == 2) || (k == 0)))
- {
- a = b;
- cin >> b;
- k = 2;
- continue;
- }
- if (a < b)
- {
- k = 5;
- break;
- }
- }
- }
- if (a < b)
- {
- for (int i = 1; i < n; i++)
- {
- if ((a < b) && ((k == 3) || (k == 0) || (k == 6)))
- {
- a = b;
- cin >> b;
- k = 3;
- continue;
- }
- if ((a <= b) && ((k == 0) || (k == 3) || (k == 4)))
- {
- a = b;
- cin >> b;
- k = 4;
- continue;
- }
- if (a > b)
- {
- k = 5;
- break;
- }
- }
- }
- if ((k == 1) || (k == 3))
- {
- cout << "2";
- }
- if ((k == 2) || (k == 4))
- {
- cout << "1";
- }
- if ((k == 5) || (k == 6))
- {
- cout << "0";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement