-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1399B.cpp
More file actions
39 lines (36 loc) · 680 Bytes
/
Copy path1399B.cpp
File metadata and controls
39 lines (36 loc) · 680 Bytes
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
#include <iostream>
#include <algorithm>
using namespace std;
int
main ()
{
long long int t, T;
cin >> T;
for (t = 0; t < T; t++)
{
int n,i;
cin >> n;
long long int a1[100],a2[100],min1=1000000000,min2=1000000000,c=0;
for(i=0;i<n;i++)
{
cin >> a1[i];
if(a1[i] < min1)
{
min1 = a1[i];
}
}
for(i=0;i<n;i++)
{
cin >> a2[i];
if(a2[i] < min2)
{
min2 = a2[i];
}
}
for(i=0;i<n;i++)
{
c += max((a1[i]-min1), (a2[i]-min2));
}
cout << c << endl;
}
}