#include<bits/stdc++.h> usingnamespacestd; constint MAXN = 2e3 + 5; int n, m; structNode{ int a, b; } rob[MAXN], sc[MAXN], tmp[MAXN * MAXN], tmp2[MAXN * MAXN]; int cnt, cnt2; inlineboolcmp(Node &x, Node &y){ if (x.a == y.a) return x.b > y.b; // 排序函数必须严格偏序,否则会出现未知错误 return x.a > y.a; }
set<pair<int, int> > s; intmain(){ scanf("%d %d", &n, &m); for (int i = 1; i <= n; ++i) { scanf("%d %d", &rob[i].a, &rob[i].b); } for (int i = 1; i <= m; ++i) { scanf("%d %d", &sc[i].a, &sc[i].b); if (s.count(make_pair(sc[i].a, sc[i].b))) { continue; } s.insert(make_pair(sc[i].a, sc[i].b)); for (int j = 1; j <= n; ++j) { if (sc[i].a >= rob[j].a && sc[i].b >= rob[j].b) { tmp[++cnt].a = sc[i].a - rob[j].a + 1; tmp[cnt].b = sc[i].b - rob[j].b + 1; } } } if (!cnt) { puts("0"); return0; } sort(tmp + 1, tmp + 1 + cnt, cmp); tmp2[++cnt2] = tmp[1]; int cur = 1; for (int i = 2; i <= cnt; ++i) { if (tmp[i].b > tmp2[cur].b) { ++cur; tmp2[++cnt2] = tmp[i]; } }
// int ans = tmp2[1].a + tmp2[cnt2].b; int ans = min(tmp2[1].a, tmp2[cnt2].b); for (int i = 1; i < cnt2; ++i) { ans = min(ans, tmp2[i].b + tmp2[i + 1].a); } printf("%d\n", ans); }
intmain(){ for (int i = 1; i <= 6; ++i) { scanf("%d", &a[i]); }
int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &b[i]); }
for (int i = 1; i <= n; ++i) { for (int j = 1; j <= 6; ++j) { c[i][j] = b[i] - a[j]; } } if (n == 1) { puts("0"); return0; }
int ans = INF;
for (int k = 1; k <= 6; ++k) { vector<pair<int, int> > v;
for (int i = 2; i <= n; ++i) { int l = INF, r = INF; for (int j = 1; j <= 6; ++j) { if (c[i][j] >= c[1][k]) { r = min(r, c[i][j] - c[1][k]); } if (c[i][j] <= c[1][k]) { l = min(l, c[1][k] - c[i][j]); } }