题目
分析
代码
1 #include<iostream>
2 #include<algorithm>
3 using namespace std;
4 long long a[1001],b[1001];
5 bool cmp(long a,long long b)
6 {
7 return a>b;
8 }
9 int main ()
10 {
11 int n;
12 cin>>n;
13 for (int i=1;i<=n;i++) cin>>a[i];
14 for (int i=1;i<=n;i++) cin>>b[i];
15 sort(a+1,a+1+n);
16 sort(b+1,b+1+n,cmp);
17 long long ans=0;
18 for (int i=1;i<=n;i++)
19 ans+=a[i]*b[i];
20 cout<<ans;
21 }