A. Min Max Swap
You are given two arrays
- Select an index
i (1≤i≤n ) and swapai withbi (i. e.ai becomesbi and vice versa).
Find the minimum possible value of
The input consists of multiple test cases. The first line contains a single integer
The first line of each test case contains an integer
The second line of each test case contains
The third line of each test case contains
For each test case, print a single integer, the minimum possible value of
In the first test, you can apply the operations at indices
In the second test, no matter how you apply the operations,
In the third test, you can apply the operation at index
Solution:
This question solution is updated within contest time. please click on follow button and subscribe our channel.if you follow then get notification of answer as soon as possible.
#include
ReplyDeleteusing namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int max=-1;
int min=-1;
int a[n];
for(int i=0; i>y;
a[i]=y;
}
int b[n];
for(int j=0; j>y;
b[j]=y;
}
for(int k=0;k<n;k++){
if(a[k]<b[k]){
int x=a[k];
a[k]=b[k];
b[k]=x;
}
}
cout<<(*max_element(a,a+n))*(*max_element(b,b+n))<<endl;
}
}