forked from nikzsaz/Codeforces-solution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path350A-Tl.cpp
More file actions
41 lines (41 loc) · 641 Bytes
/
Copy path350A-Tl.cpp
File metadata and controls
41 lines (41 loc) · 641 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
#include <iostream>
using namespace std;
int maxee(int a,int b){
return a>b?a:b;
}
int main() {
int arr[101],arr1[101];
int n,m;
cin>>n>>m;
int flag=0;
for(int i=0;i<n;i++){
cin>>arr[i];
}
for(int i=0;i<m;i++){
cin>>arr1[i];
}
int max=arr[0];
int min1=arr[0];
for(int i=0;i<n;i++){
if(max<arr[i]){
max=arr[i];
}
if(min1>arr[i]){
min1=arr[i];
}
}
int val=maxee(2*min1,max);
int min=arr1[0];
for(int i=0;i<m;i++){
if(min>arr1[i]){
min=arr1[i];
}
}
if(val<min){
cout<<val;
}
else{
cout<<"-1";
}
return 0;
}