#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 1e5 + 10;
int n1,n2, a[maxn], b[maxn], ans;
vector<int>z1, z2, f1, f2;
bool comp(int x, int y)
{
return x > y;
}
int main()
{
scanf("%d", &n1);
for (int i = 0; i < n1; i++)
{
scanf("%d", &a[i]);
}
sort(a, a + n1, comp);
scanf("%d", &n2);
for (int i = 0; i < n2; i++)
{
scanf("%d", &b[i]);
}
sort(b, b + n2, comp);
for (int i = 0; i < min(n1, n2); i++)
{
if (a[i] > 0 && b[i] > 0)ans += a[i] * b[i];
else break;
}
for (int i = n1 - 1, j = n2 - 1; i >= 0, j >= 0; i--, j--)
{
if (a[i] < 0 && b[j] < 0)ans += a[i] * b[j];
else break;
}
printf("%d", ans);
return 0;
}
1037 Magic Coupon(25 分)
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- The magic shop in Mars is offering some magic coupons. Ea...
- 台湾人把人生打怪通关的技能配置,按其所起的作用大小做了排序: 一命二运三风水四积德五读书,我自己偷偷加了一个,六健...
- 最近自己陷入到一个怪圈里,焦躁,狂躁,焦虑。然后伴随着我,让我整个人处在一个既沉闷又癫狂的一个状态。 我自己心里的...