-
Notifications
You must be signed in to change notification settings - Fork 2
/
FASHION.c
53 lines (49 loc) · 855 Bytes
/
FASHION.c
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
46
47
48
49
50
51
52
53
#include<stdio.h>
void quicksort(int A[],int LB,int UB)
{
int i,j,pivot,temp;
if(LB<UB)
{
pivot=LB;
i=LB;
j=UB;
while(i<j)
{
while(A[i]<=A[pivot]&&i<UB)
i++;
while(A[j]>A[pivot])
j--;
if(i<j)
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
temp=A[j];
A[j]=A[pivot];
A[pivot]=temp;
quicksort(A,LB,j-1);
quicksort(A,j+1,UB);
}
}
int main()
{
int test, N, M, ans, i ,men[1001], women[1001];
scanf("%d",&test);
while (test--)
{
ans = 0;
scanf("%d",&N);
for(i=0;i<N;i++)
scanf("%d",&men[i]);
for(i=0;i<N;i++)
scanf("%d",&women[i]);
quicksort(men,0,N-1);
quicksort(women,0,N-1);
for(i=0;i<N;i++)
ans += men[i] * women[i];
printf("%d\n", ans);
}
return 0;
}