-
Notifications
You must be signed in to change notification settings - Fork 2
/
fashionshows.java
31 lines (30 loc) · 1.01 KB
/
fashionshows.java
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
import java.util.Scanner;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int n=sc.nextInt();
int m[]=new int[n];
int w[]=new int[n];
int x=0;
while(x<n){
m[x++]=sc.nextInt();
}
Arrays.sort(m);
x=0;
while(x<n){
w[x++]=sc.nextInt();
}
Arrays.sort(w);
x=0;
int sum=0;
while(x<n){
sum+=m[x]*w[x];
x++;
}
System.out.println(sum);
}
}
}