-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddingarray.c++
More file actions
42 lines (36 loc) · 864 Bytes
/
addingarray.c++
File metadata and controls
42 lines (36 loc) · 864 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
#include <bits/stdc++.h>
using namespace std;
#define vl vector<long>
int main() {
short t;
cin>>t;
while(t--){
short n;
cin>>n;
vl a(n);
for(auto &i:a){
cin>>i;
}
vl b(n-1);
for(auto &i:b){
cin>>i;
}
sort(b.begin(),b.end());
if(n==2){
int n=b[0]-a[0];
int m=b[0]-a[1];
cout<<abs(min(n,m))<<endl;//to convert all negative sign to postive we can use function abs() for integer ans fabs() for float and dabs() for double
}
else{
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int x=b[n-2]-a[i];
int y=b[n-3]-a[j];
if(x==y){
cout<<y<<endl;
}
}
}}
}
return 0;
}