-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFASHION.c
More file actions
56 lines (55 loc) · 1.02 KB
/
Copy pathFASHION.c
File metadata and controls
56 lines (55 loc) · 1.02 KB
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
54
55
56
#include<stdio.h>
int main()
{
int t,n,a[1000],b[1000],i,j,ntemp,r,temp;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
i=0;
ntemp=n;
while(ntemp--)
{
scanf("%d",&a[i]);
i++;
}
ntemp=n;
i=0;
while(ntemp--)
{
scanf("%d",&b[i]);
i++;
}
r=0;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(b[i]>b[j])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
}
}
for(i=0;i<n;i++)
{
r=r+a[i]*b[i];
}
printf("%d\n",r);
}
return 0;
}