-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
52 lines (47 loc) · 904 Bytes
/
B.cpp
File metadata and controls
52 lines (47 loc) · 904 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
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;
void moves(int n ,vector <int> a,vector <int> b)
{
int m=*min_element(a.begin(),a.end());
int M=*min_element(b.begin(),b.end());
//cout<<"max"<<m<<M<<endl;
int i=0,o,oo;
long long c=0;
while(i<n)
{
/* if(a[i]==m && b[i]==M)
{
i++;
continue;
}*/
o=a[i]-m;
oo=b[i]-M;
//cout<<o<<oo<<endl;
c+=max(o,oo);
a[i]=a[i]-o;
b[i]=b[i]-oo;
i++;
}
cout<<c<<endl;
}
int main()
{
int t,n;
cin>>t;
for(int i=0;i<t;i++)
{
cin>>n;
vector <int> a(n);
vector <int> b(n);
for(int j=0;j<n;j++)
{
cin>>a[j];
}
for(int j=0;j<n;j++)
{
cin>>b[j];
}
moves(n,a,b);
}
return 0;
}