-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSORT7.c
44 lines (42 loc) · 803 Bytes
/
SORT7.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
//Author Pulkit Singh
#include <stdio.h>
void result(int a[], int b[], int n) {
int i, j, t, s = 0;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (a[i] > a[j]) {
t = a[i];
a[i] = a[j];
a[j] = t;
}
if (b[i] < b[j]) {
t = b[i];
b[i] = b[j];
b[j] = t;
}
}
}
for (i = 0; i < n; i++) {
s = s + (a[i] * b[i]);
}
printf("%d", s);
}
int main() {
int t, v, w;
scanf("%d", & t);
int m[t], c[t][100], d[t][100];
for (v = 0; v < t; v++) {
scanf("%d", & m[v]);
for (w = 0; w < m[v]; w++) {
scanf("%d", & c[v][w]);
}
for (w = 0; w < m[v]; w++) {
scanf("%d", & d[v][w]);
}
}
for (v = 0; v < t; v++) {
result(c[v], d[v], m[v]);
printf("\n");
}
return 0;
}