-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCADYDIST.cpp
More file actions
34 lines (33 loc) · 755 Bytes
/
CADYDIST.cpp
File metadata and controls
34 lines (33 loc) · 755 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
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
long long int result ;
vector<long long int> class1;
vector<long long int> price1;
int N;
cin>>N;
while(N!=0){
result = 0 ;
for(int i=0; i <N;i++){
int cl;cin>>cl;
class1.push_back(cl);
}
for(int i=0; i <N;i++){
int pr;cin>>pr;
price1.push_back(pr);
}
sort(class1.begin(),class1.end());
sort(price1.begin(),price1.end());
int i=0,j=N-1;
while(i!=N){
result+=price1[j]*class1[i];
i++;j--;
}
cout<<result<<endl;
class1.clear();
price1.clear();
cin>>N;
}
}