artemgf

Одномерный лабиринт

Apr 15th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <set>
  6. #include <map>
  7. #include <algorithm>
  8. #include <string>
  9. #include <math.h>
  10. #include <vector>
  11. #include <cmath>
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17.     int n, x, pol= 100000, at=-100000;
  18.  
  19.     cin >> n >> x;
  20.  
  21.     for (int i = 1; i <= n; i++)
  22.     {
  23.         int prom;
  24.         cin >> prom;
  25.         if (prom > 0)
  26.             if (prom < pol)
  27.                 pol = prom;
  28.             else;
  29.         else
  30.             if (prom > at)
  31.                 at = prom;
  32.             else;
  33.     }
  34.  
  35.     if (at < x&&x < pol)
  36.         if(x>0)
  37.             cout << x << " " << abs(at) + abs(at) + x;
  38.         else
  39.             cout << abs(pol + pol - x) << " " << abs(x);
  40.     else
  41.         cout << "Impossible";
  42.     system("pause");
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment