Codeforces Round #203 (Div. 2) A.TL

OpenSoucre發表於2013-10-10
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int minCorrectTime  =1000, maxCorrectTime = 0, minWrongTime = 1000,tmp;
    for(int i = 0 ; i < n; i ++){
        cin >> tmp;
        minCorrectTime = min(tmp,minCorrectTime);
        maxCorrectTime = max(tmp,maxCorrectTime);
    }
    for(int i = 0 ; i < m ; ++ i ){
        cin >> tmp;
        minWrongTime = min(minWrongTime,tmp);
    }
    if(maxCorrectTime < minWrongTime && 2*minCorrectTime < minWrongTime) cout<<max(maxCorrectTime,2*minCorrectTime)<<endl;
    else cout<<-1<<endl;
    return 0;
}

 

相關文章