Advertisement
K_Y_M_bl_C

Untitled

Dec 18th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. int n;
  2. pair<ll, ll> a[1007];
  3.  
  4. int main()
  5. {
  6.     scanf("%d", &n);
  7.     forn(i, n)
  8.         scanf("%lld %lld", &a[i].X, &a[i].Y);
  9.     sort(a, a + n);
  10.     forn(i, n)
  11.     {
  12.         ll S = a[i].X;
  13.         ll A = a[i].Y;
  14.         int f = 1;
  15.         for (int i = 0; i < n; ++i)
  16.         {
  17.             ll q = max(0ll, A - abs(a[i].X - S));
  18.             if (q != a[i].Y)
  19.                 f = 0;
  20.         }
  21.         if (f && abs(S) <= 1000000000 && A >= 0 && A <= 1000000000)
  22.         {
  23.             puts("YES");
  24.             printf("%lld %lld", S, A);
  25.             exit(0);
  26.         }
  27.     }
  28.     for (int L = 0; L < n - 1; ++L)
  29.     {
  30.         ll A = a[L].Y + a[L + 1].Y - a[L].X + a[L + 1].X;
  31.         if ((A & 1) == 0)
  32.         {
  33.             A /= 2;
  34.             ll S = A - a[L + 1].Y + a[L + 1].X;
  35.             if (a[L].X <= S && S <= a[L + 1].X)
  36.             {
  37.                 int f = 1;
  38.                 for (int i = 0; i < n; ++i)
  39.                 {
  40.                     ll q = max(0ll, A - abs(a[i].X - S));
  41.                     if (q != a[i].Y)
  42.                         f = 0;
  43.                 }
  44.                 if (f && abs(S) <= 1000000000 && A >= 0 && A <= 1000000000)
  45.                 {
  46.                     puts("YES");
  47.                     printf("%lld %lld", S, A);
  48.                     exit(0);
  49.                 }
  50.             }
  51.         }
  52.     }
  53.     puts("NO");
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement