-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCTDL042.cpp
42 lines (39 loc) · 844 Bytes
/
SCTDL042.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file SCTDL042.cpp
* @author long ([email protected])
* @brief
* @version 0.1
* @date 2023-03-13
*
* @copyright Copyright (c) 2023
*
*/
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int t;
std::cin >> t;
while (t--) {
int n;
std::vector<int> vta, vtb;
std::cin >> n;
for(int i=0; i<n; i++) {
int tmp;
std::cin >> tmp;
vta.push_back(tmp);
}
for(int i=0; i<n; i++) {
int tmp;
std::cin >> tmp;
vtb.push_back(tmp);
}
sort(vta.begin(), vta.end());
sort(vtb.begin(), vtb.end());
long long int product{0};
for(int i=0; i<n; i++) {
product += vta[i] * vtb[n-1-i];
}
std::cout << product << std::endl;
}
}