Codeforces 2051E. 二分5
原题链接
简单
作者:
Dessa
,
2025-01-09 15:42:32
,
所有人可见
,
阅读 3
浆糊的脑子
const int N = 1e6 + 10;
int a[N], b[N];
int n, k;
int cheak(int x)
{
int l = lower_bound(b + 1, b + 1 + n, x) - b;
int r = lower_bound(a + 1, a + 1 + n, x) - a;
r--;
if (r - l + 1 > k) return 0;
else return (n - l + 1) * x;
}
void solve()
{
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
sort(a + 1, a + 1 + n);
sort(b + 1, b + 1 + n);
int mmax = 0;
for (int i = 1; i <= n; i++)
{
mmax = max(mmax, cheak(a[i]));
mmax = max(mmax, cheak(b[i]));
}
cout << mmax << '\n';
}