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, a, b, k, max, min;
- a = -1;
- b = -1;
- max = -2147483646;
- min = 2147483647;
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- cin >> k;
- if ((k % 2) == 0)
- {
- if (k >= max)
- {
- max = k;
- }
- }
- else
- {
- if (k <= min)
- min = k;
- }
- if ((max == -2147483646) && (min == 2147483647))
- {
- break;
- }
- }
- if (min == 2147483647)
- cout << "-1" << " ";
- else
- cout << min << " ";
- if (max == -2147483646)
- cout << "-1";
- else
- cout << max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement