-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfashion.cpp
More file actions
38 lines (36 loc) · 716 Bytes
/
fashion.cpp
File metadata and controls
38 lines (36 loc) · 716 Bytes
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
#include <iostream>
#include <algorithm>
#include <bitset>
#include <string>
#include <vector>
#include <utility>
#include <list>
#include <set>
#include <map>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
// freopen("../output.txt", "w", stdout);
int test_cases;
cin >> test_cases;
while (test_cases--) {
int n, x;
vector <long long int> men, women;
cin >> n;
for (int i=0; i<n; i++) {
cin >> x;
men.push_back(x);
}
for (int i=0; i<n; i++) {
cin >> x;
women.push_back(x);
}
sort(men.begin(), men.end());
sort(women.begin(), women.end());
long long int res = 0;
for (int i=0; i<n; i++)
res += men[i] * women[i];
cout << res << endl;
}
return 0;
}