Code:
#include<cstdio> #include<map> #include<iostream> #include<cmath> #include<bitset> using namespace std; const int maxn = 100000 + 3; map<double, int> idx; int val[maxn], l[maxn], r[maxn], cnt; bitset<130> Gleft[40000], Gright[40000]; inline double getinter(int a, int b){ return (double) min(a, b) + abs(a - b) / 2; } int main(){ int n, m; cin >> n >> m; for(int i = 1;i <= n; ++i) scanf("%d",&l[i]); for(int i = 1;i <= m; ++i) scanf("%d",&r[i]); for(int i = 1;i <= n; ++i) for(int j = 1;j <= m; ++j){ double inter = getinter(l[i], r[j]); if(!idx[inter]) idx[inter] = ++cnt; Gleft[idx[inter]].set(i, 1); Gright[idx[inter]].set(j, 1); } int ans = 0; for(int i = 1;i <= cnt; ++i) for(int j = 1;j <= cnt; ++j) { bitset<130>A, B; A = Gleft[i] | Gleft[j]; B = Gright[i] | Gright[j]; int cur = A.count() + B.count(); ans = max(ans, cur); } cout << ans; return 0; }