allia

монотонные последовательности

Sep 10th, 2020
1,399
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  long long a=0, max=0, min=1000000000000;
  8.  
  9.  cin >> a;
  10.  long long arr[a];
  11.  
  12.  for (int i=0; i<a; i++)
  13.  cin >> arr[i];
  14.  
  15. for (int i=0; i<a; i++)
  16.   {
  17.     if (arr[i]%2==0 && arr[i]>max)
  18.       max = arr[i];
  19.     if (arr[i]%2!=0 && arr[i]<min)
  20.       min = arr[i];
  21.   }
  22.  
  23. if (min == 1000000000000)
  24. cout << -1 << " ";
  25. else cout << min << " ";
  26.  
  27. if (max==0)
  28. cout << -1;
  29. else cout << max;
  30. }
RAW Paste Data