1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #include<bits/stdc++.h>
using namespace std;
const int N = 1e6+10; struct Point { int x, y; } p[N];
bool cmp1(const Point &a, const Point &b) { return a.x < b.x; }
bool cmp2(const Point &a, const Point &b) { return a.y < b.y; }
int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i].x >> p[i].y; } sort(p + 1, p + n + 1, cmp1); int max_dist = p[n].x - p[1].x; sort(p + 1, p + n + 1, cmp2); max_dist = max(max_dist, p[n].y - p[1].y);
int res = max_dist % 2 == 0 ? max_dist / 2 : max_dist / 2 + 1; cout << res << endl; return 0; }
|