-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathID1025.cpp
45 lines (32 loc) · 1 KB
/
ID1025.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
43
44
45
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
using namespace std; //Required Headers;
int main(){
int T;cin>>T; //No of test cases;
while(T!=0){
int N;cin>>N; //No of Participants;
int K = N;
vector<int> MensHotness; // List of Hotness of Participants;
vector<int> WomenHotness;
while(N!=0){ // Input Hotness of Participants;
int Hm;cin>>Hm;
MensHotness.push_back(Hm);
N--;
}
while(K!=0){
int Hw;cin>>Hw;
WomenHotness.push_back(Hw);
K--;
}
int maxHotness = 0 ; //Sorting the hortness of participants
sort(MensHotness.begin(),MensHotness.end());
sort(WomenHotness.begin(),WomenHotness.end());
//calculating Maximum hotness of participants.
for(int i = 0;i<MensHotness.size();++i){
maxHotness = maxHotness + (MensHotness[i]*WomenHotness[i]);
}
cout<<maxHotness<<endl;
T--;
}
}