-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaxscalar.cpp
More file actions
43 lines (37 loc) · 832 Bytes
/
Copy pathmaxscalar.cpp
File metadata and controls
43 lines (37 loc) · 832 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
39
40
41
42
43
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int arr1[n];
for(int i=0;i<n;i++){
cin>>arr1[i];
}
int arr2[n];
for(int i=0;i<n;i++){
cin>>arr2[i];
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(arr1[i]>arr2[j]){
int temp=arr1[i];
arr1[i]=arr2[j];
arr1[j]= temp;
}
}
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(arr1[i]>arr2[j]){
int temp=arr1[i];
arr1[i]=arr2[j];
arr1[j]= temp;
}
}
}
int product=0;
for(int i=0;i<n;i++){
product+= arr1[i]+arr2[i];
}
cout<<product;
}