Advertisement
agul

20130105 :: Timus :: B

Jan 5th, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cstdio>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. #define fill(a, x) memset (a, x, sizeof(a))
  8.  
  9. const int INF = 0x3f3f3f3f;
  10.  
  11. int n, x, y, a[1111][1111], mn, ans, curd;
  12. double xx, yy;
  13.  
  14. int main() {
  15.     scanf("%d", &n);
  16.     fill(a, 0);
  17.     for (int i = 0; i < n; ++i) {
  18.         scanf("%lf%lf", &xx, &yy);
  19.         x = (int)(xx * 1000) % 1000;
  20.         y = (int)(yy * 1000) % 1000;
  21.         if (x < 0) x += 1000;
  22.         if (y < 0) y += 1000;
  23.         ++a[x][y];
  24.     }
  25.     mn = INF;
  26.     ans = 0;
  27.     for (int i = 0; i < 1000; ++i)
  28.         for (int j = 0; j < 1000; ++j) {
  29.             x = min(abs(i - 1000), i);
  30.             y = min(abs(j - 1000), j);
  31.             curd = x * x + y * y;
  32.             if (a[i][j] > ans) {
  33.                 ans = a[i][j];
  34.                 mn = curd;
  35.             } else
  36.             if (a[i][j] == ans) mn = min(mn, curd);
  37.         }
  38.     printf("%d %.16lf", ans, sqrt(mn + 0.) / 1000);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement